I am trying to explode empty line.
Here is my string variable:
$string = '
Hello,
Just test lines
Second test lines
';
I want these results:
$OUTPUT[0]='HELLO,';
$OUTPUT[1]='Just test lines
Second test lines';
My code:
$a = explode("\n\n",$string);
print_r($a);
My field results:
Array ( [0] => Hello, Just test lines Second test lines )
This should do the trick:
$string = '
Hello,
Just test lines
Second test lines
';
$data = preg_split("#\n\s*\n#Uis", $string);
print_r($data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With