Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts

    preg_replace help

    PHP Code:
    $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

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Looks like you have to escape the parenthesis (put a slash in front of it).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •