note 87944 added to function.preg-replace
| From: | callummann at blueyonder dot co dot uk | Date: | Thu, 01 Jan 2009 00:31:16 +0000 |
| Subject: | note 87944 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148735@lists.php.net to get a copy of this message | ||
For BBcode, rather than having two different arrays you can use the same one.
<?php
$bbcode = array(
"/\[b\](.*?)\[\/b\]/is" => "<strong>$1</strong>",
"/\[u\](.*?)\[\/u\]/is" => "<u>$1</u>",
"/\[url\=(.*?)\](.*?)\[\/b\]/is" => "<a
href='$1'>$2</a>"
);
$text = "[b]Text[/b][u]Text[/u]";
$text = preg_replace(array_keys($bbcode), array_values($bbcode), $text);
?>
----
Server IP: 64.71.164.2
Probable Submitter: 82.32.49.122
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/87944
Del: integrated -- https://master.php.net/note/delete/87944/integrated
Del: useless -- https://master.php.net/note/delete/87944/useless
Del: bad code -- https://master.php.net/note/delete/87944/bad+code
Del: spam -- https://master.php.net/note/delete/87944/spam
Del: non-english -- https://master.php.net/note/delete/87944/non-english
Del: in docs -- https://master.php.net/note/delete/87944/in+docs
Del: other reasons-- https://master.php.net/note/delete/87944
Reject -- https://master.php.net/note/reject/87944
Search -- https://master.php.net/manage/user-notes.php