I’ve always used this with great success:
$array = preg_split("/\r\n|\n|\r/", $string);
(updated with the final \r, thanks @LobsterMan)
More Related Contents:
- How can I put strings in an array, split by new line?
- How can I get a hex dump of a string in PHP?
- Remove new lines from string and replace with one empty space
- PHP, get file name without file extension
- URL Friendly Username in PHP?
- PHP: Split string [duplicate]
- Mixing a PHP variable with a string literal
- PHP equivalent of .NET/Java’s toString()
- How to mimic Stack Overflow Auto-Link Behavior
- how to replace special characters with the ones they’re based on in PHP?
- How can I truncate a string to the first 20 words in PHP?
- Remove control characters from PHP string
- Convert flat array to a delimited string to be saved in the database
- How do I linkify urls in a string with php?
- PHP Echo Line Breaks
- How to split a string by multiple delimiters in PHP?
- Check whether $_POST-value is empty
- How to get email address from a long string
- line breaks in a textarea
- String contains any items in an array (case insensitive)
- Structure of a Serialized PHP string
- How to cast array elements to strings in PHP?
- How to reverse a Unicode string
- remove duplicate from string in PHP
- How to Convert Boolean to String
- Delete first 3 characters and last 3 characters from String PHP
- How can I get the last 7 characters of a PHP string?
- Convert a String to Variable
- How to convert all characters to their html entity equivalent using PHP
- Limit String Length