Preg_replace

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Preg_replace

Post by pinehead18 »

Code: Select all

$smilies[0] = "/:)/";
$smilies[1] = "/:(/";
$replace_smilies[0] = "<img src=/forums/images/icon.gif";
				
$body = preg_replace($smilies, $replace_smilies, $body);

echo $body;
My code

Error from my code
Warning: Compilation failed: unmatched parentheses at offset 1 in /www/forums/viewtopic on line 82

Thank you for any help you con provide.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

escape the parens used in the patterns.
Post Reply