...

View Full Version : preg_replace help



ole90
08-14-2007, 08:50 PM
$patterns[0] = "/:)/";
$patterns[1] = "/:(/";
$patterns[2] = "/:D/";
$replacements[0] = "<img src='images/smilies/happy.gif'>";
$replacements[1] = "<img src='images/smilies/sad.gif'>";
$replacements[2] = "<img src='images/smilies/vhappy.gif'>";
preg_replace($patterns, $replacements, $message);


I'm trying to replace the smilies codes with images. But it returns this error:

Warning: preg_replace() [function.preg-replace]: Compilation failed: unmatched parentheses at offset 1 in /home/fantasy3/public_html/ichuson/smilies.php on line 9

Fumigator
08-14-2007, 08:58 PM
Looks like you have to escape the parenthesis (put a slash in front of it).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum