Re: how can i get rid of newlines?
| From: | Marek Kilimajer | Date: | Sat, 29 Nov 2003 03:36:08 +0000 |
| Subject: | Re: how can i get rid of newlines? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-171315@lists.php.net to get a copy of this message | ||
David T-G wrote:
Marek, et al -- ...and then Marek Kilimajer said... % % $string = str_replace("\n", '<br>', $string); That didn't work for me. Interestingly enough, in light of Leif's post, neither did \r\n in the search pattern. Hmmph. Well, thank heavens once again for preg_replace() :-) Thanks & HAND :-DRight, I did not think about dos (\r\n) newlines. But Leif's code does not consider mac newlines (\r) :-). This takes care of all: $string = str_replace(array("\r\n","\n","\r"), '<br>', $string);