|  | Posted by Toby Inkster on 03/12/06 02:06 
Janwillem Borleffs wrote:
 > Simon wrote:
 >> Just out of curiosity, would it work if $needle, $str, $haystack had
 >> escape/special characters?
 >
 > Good point. You need to escape reserved regular expression characters in
 > $needle as follows:
 >
 > if (!function_exists('str_ireplace')) {
 >     function str_ireplace($needle, $str, $haystack) {
 >         $needle = preg_quote($needle, '/');
 >         return preg_replace("/$needle/i", $str, $haystack);
 >     }
 > }
 >
 > $str and $haystack do not need to be modified.
 
 What if $str contained "\1"?
 
 --
 Toby A Inkster BSc (Hons) ARCS
 Contact Me  ~ http://tobyinkster.co.uk/contact
 [Back to original message] |