faster replace

Discussion in 'PHP' started by trichnosis, Oct 25, 2007.

  1. #1
    Hi;

    I have written some php code.

    This code is making heavy letter replacement.

    Which is the faster character replacement way?

    $txt = str_replace($search,$replace,$txt); or $txt = preg_replace($search , $replace , $txt);

    which one must i use for making my code faster?

    Thanks for the comments
     
    trichnosis, Oct 25, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    str_replace() is a lot faster.
     
    nico_swd, Oct 25, 2007 IP