How can I put strings in an array, split by new line?

I’ve always used this with great success:

$array = preg_split("/\r\n|\n|\r/", $string);

(updated with the final \r, thanks @LobsterMan)

Leave a Comment