note 56248 deleted from function.highlight-string by mazzanet
| From: | mazzanet@php.net | Date: | Sun, 28 Aug 2005 21:10:40 +0000 |
| Subject: | note 56248 deleted from function.highlight-string by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-94313@lists.php.net to get a copy of this message | ||
Note Submitter:
----
on the code you ave a few errors:
Error:Unexpected { , Expecting (
Fixed that below:
function bb_url($str) {
return preg_replace('#[URL=([^\']*)]([^\']*)[/URL]#', '<a
href="\\1" target=_blank>\\2</a>', $str);
}
function bb_php($str) {
$str = str_replace("]\n", "]", $str);
$match = array('#\[php\](.*?)\[\/php\]#se');
$replace = array("'<div>'.highlight_string(stripslashes('$1'),
true).'</div>'");
return preg_replace($match, $replace, $str);
}
function bb_img($str) {
return preg_replace('#[IMG]([^\']*)[/IMG]#', '<img src="\\1"
/>', $str);
}
function bb_b($str) {
return preg_replace('#[B]([^\']*)[/B]', '<strong>\\1</strong>',
$str);
}
function bb_i($str) {
return preg_replace('#[I]([^\']*)[/I]', '<em>\\1</em>', $str);
}
function bb_parse($str) {
$str = bb_url($str);
$str = bb_php($str);
$str = bb_img($str);
$str = bb_b($str);
$str = bb_i($str);
return $str
}