Php explode string by newline


Php explode string by newline : You can use PHP_EOL to explode string at line break.


Php explode string by newline break

$array = explode(PHP_EOL, $string);

Which will break the string at the break line.

Php explode array at line break Example

$string = " str1 
            str2
            str3";
$array = explode(PHP_EOL, $string);
print_r($array);
array('0'=>'str1','1'=>'str2','2'=>'str3');

Advertisements

Add Comment

📖 Read More