Ask how to split the TXT file by blank line,
Ask how to split the TXT file by blank line,
such as TXT file a.txt
The contents are as follows:
Oh, ah, yes.
Uh, uh,
111111
222222
Quack Gaga
Quack Gaga
There is a blank line in it, how to press the blank line to cut it into a paragraph of the string?
------to solve the idea----------------------
If it is a blank line to split it will find two lines (\ r \ n)
$str = ' 123
Defsf
Abc
1213
&* (
';
Print_r (Explode ("\n\r", $str)); Equivalent to Print_r (Explode ("\r\n\r\n", $str));
or use regular
Preg_match ('/[^.] +? (? =\r\n\r\n)/', $STR, $mat);
Print_r ($mat);
------to solve the idea----------------------
$s =<<< TXT
Oh, ah, yes.
Uh, uh,
111111
222222
Quack Gaga
Quack Gaga
TXT;
$a = Preg_split ("/([\r\n]+) \\1/", $s);
Print_r ($a);
Array
(
[0] Oh ah ah ah
Uh, uh,
[1] = 111111
222222
[2] = = Quack Gaga
Quack Gaga
)