note 24789 deleted from function.str-replace by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Wed, 28 Aug 2002 21:45:44 +0000 |
| Subject: | note 24789 deleted from function.str-replace by jmcastagnetto | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-35941@lists.php.net to get a copy of this message | ||
About case insensitive replace stri_replace, I have to add a bug filter to anton@titov.info
solution:
function stri_replace($old, $new, $haystack){
return preg_replace('/'.str_replace('/', '\/',
quotemeta($old)).'/i', $new, $haystack);
}
I do add the '/' escaping as preg_replace need the '/' for its own use...
Now I can stri-replace '</head>' :)
Also, I found another problem...
I want to change '</tag>' to '$1</tag>'... The '/' is well
found, but the $1 is interpreted by preg_replace as a internal capturing ()... ARG !
Any idea ?