Monday, 20 August 2012

Favour str_replace() over ereg_replace() and preg_replace()


Str Replace
Speed tests show that str_replace() is 61% faster.
In terms of efficiency, str_replace() 10 is much more efficient than regular expressions at replacing strings. In fact, according to Making the Web, str_replace() is 61% more efficient than regular expressions like ereg_replace() 11 and preg_replace() 12.
If you’re using regular expressions, then ereg_replace() and preg_replace() will be much faster than str_replace().

No comments:

Post a Comment