Hello, i am stuck at making a emoticon system for my new script. the problem is i don't have any knowledge of regex at all so i am not able to convert the code of smiley into an image. heres what i tried: $string="Smile: [smiley]"; preg_replace("/\[(.*?)\]/","<img src='images/$1.gif'>",$string); PHP: plz help me this is first time i am using preg_replace
That should work. What's not working for you? That would output: Smile: <img src='images/smiley.gif'>
Maybe he's stuck with how to output it? <?php $string="Smile: [smiley]"; $replacement = preg_replace('#\[(.*?)\]#','<img src=\'images/$1.gif\'>',$string); echo $replacement; ?> PHP:
oops silly error on my side i interpreted the example on php.net wrongly. anyways its working now thx