note 56018 deleted from function.preg-replace by derek

From: Date: Sat, 20 Aug 2005 23:02:53 +0000
Subject: note 56018 deleted from function.preg-replace by derek
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-93970@lists.php.net to get a copy of this message
Note Submitter: Reason: bad code ---- Some BB-codes width preg_replace: <?php 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 } ?>

« previous php.notes (#93970) next »