note 27189 added to function.ereg-replace
| From: | catharsisnOSpAmltd at NoSpam dot hotmail dot com | Date: | Tue, 26 Nov 2002 17:04:55 +0000 |
| Subject: | note 27189 added to function.ereg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40003@lists.php.net to get a copy of this message | ||
Hi, just thought people might like to know this as I had a bit of a problem getting it to work. Say
your recieving this as text (mine is coming in via a form) and you want to convert just simple line
returns in HTML. I am assuming you might have Windows based in there. Since I cant put in the HTML
tags replace as you see necessary :)
$news = "This is a paragraph\n\nNew Line\nNew Line\nNew Line\nNew Line\n\nParagraph 2";
$news = ereg_replace("\r?\n\r?\n", "[closing p tag][opening p tag]", $news);
$news = ereg_replace("\r?\n", "[br tag]", $news);
$news = "[opening p tag]".$news."[closing p tag]";
I know what you might be thinking.. thats easy! Well for some reason it didnt work with single
quoted regular experssions. e.g.
$news = ereg_replace('\r?\n\r?\n', '[closing p tag][opening p tag]', $news);
Im not sure why the ' doesnt work and " does, but thou7gh all could benefit after I
screamed at PHP for a bit *grin*
- Chris
--
http://www.php.net/manual/en/function.ereg-replace.php
http://master.php.net/manage/user-notes.php?action=edit+27189
http://master.php.net/manage/user-notes.php?action=delete+27189
http://master.php.net/manage/user-notes.php?action=reject+27189