Home > Backend Development > PHP Tutorial > PHP regular problem, I want to match and split where (rn) appears twice

PHP regular problem, I want to match and split where (rn) appears twice

WBOY
Release: 2016-09-11 11:34:07
Original
1105 people have browsed it

<code>$str = "fhd\r\n\r\nfdfk\r\n\r\nuuuuu";
$data = preg_split("(\r\n){2}", $str, -1);
print_r($data);
</code>
Copy after login
Copy after login

Result:

PHP regular problem, I want to match and split where (rn) appears twice

Reply content:

<code>$str = "fhd\r\n\r\nfdfk\r\n\r\nuuuuu";
$data = preg_split("(\r\n){2}", $str, -1);
print_r($data);
</code>
Copy after login
Copy after login

Result:

PHP regular problem, I want to match and split where (rn) appears twice

<code>    $str = "fhd\r\n\r\nfdfk\r\n\r\nuuuuu";
    $data = preg_split("/(\r\n){2}/", $str, -1);
    print_r($data);</code>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template