note 15961 added to function.preg-replace
| From: | dl dot soluz at gmx dot net | Date: | Wed, 10 Oct 2001 15:24:09 +0000 |
| Subject: | note 15961 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18774@lists.php.net to get a copy of this message | ||
better solution for the last example:
$text="hello [b]this[/b] is a [url=http://www.test.com]link[/url]
test with [u]underline[/u] and [i]italic[/i]";
echo($text."-->");
// for [url]
$html=preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/msi","<a
href=\"\\1\">\\2</a>",$text);
// for [u],[b],[i]
$html=preg_replace("/\[(b|u|i)\](.*?)\[\/(\\1)\]/msi","<\\1>\\2</\\1>",$html);
echo($html);
--
http://www.php.net/manual/en/function.preg-replace.php
http://master.php.net/manage/user-notes.php?action=edit+15961
http://master.php.net/manage/user-notes.php?action=delete+15961
http://master.php.net/manage/user-notes.php?action=reject+15961