I'm receiving data from a MSSQL database with PHP (using PDO sqlsrv driver).
I need to split the string by new line.
In the DB the string looks like this:
I tried the following with no success:
$text = explode("\n\n",$text);
$text = preg_split("/\n\n/",$text);
Or
$text = explode("\n",$text);
$text = preg_split("/\n/",$text);
When i debug the code and when i print the text to the browser the string appears as one line.
But if i inspect the element in chrome, it is displayed exactly like in the database:
I copied the text from the inspector to a regex tester and the newlines were found successfully! But the "echoed" text was in one line.
`'s. – Funk Forty Niner Jun 06 '17 at 12:04
in the correct places, but then i need to try and split the string with
which is kinda messy... – Alex Leibovich Jun 06 '17 at 12:17
'` are messy? If you want clean HTML, use `\n` and `
`. See the answer below then, I don't know how else to help here, sorry. – Funk Forty Niner Jun 06 '17 at 12:20