Favor str_replace() Over ereg_replace() and preg_replace()
by Sanju[ Edit ] 2010-01-01 16:13:33
Favor str_replace() Over ereg_replace() and preg_replace()
If you’re using regular expressions, then
ereg_replace() and preg_replace() will be much faster than
str_replace().
Because str_replace() does not support pattern matching, this statement makes no sense. The choice between string functions and regular expression functions comes down to which is fit for purpose, not which is faster.
If you need to match a pattern, use a regular expression function. If you need to match a string, use a string function.