note 24789 added to function.str-replace
| From: | frj at thederea dot com | Date: | Wed, 28 Aug 2002 14:33:50 +0000 |
| Subject: | note 24789 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35916@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 ?
--
http://www.php.net/manual/en/function.str-replace.php
http://master.php.net/manage/user-notes.php?action=edit+24789
http://master.php.net/manage/user-notes.php?action=delete+24789
http://master.php.net/manage/user-notes.php?action=reject+24789