To expand on @renocor's answer, I've written a function that is 100% backward-compatible with str_replace[]
. That is, you can replace all occurrences of str_replace[]
with str_replace_limit[]
without messing anything up, even those using arrays for the $search
, $replace
, and/or $subject
.
The function could be completely self-contained, if you wanted to replace the function call with
[$string===strval[intval[strval[$string]]]]
, but I'd recommend against it since valid_integer[]
is a rather useful function when dealing with integers provided as strings.
Note: Whenever possible, str_replace_limit[]
will use str_replace[]
instead, so all calls to str_replace[]
can be replaced with str_replace_limit[]
without worrying about a hit to performance.
Usage