note 72719 deleted from function.str-ireplace by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 May 2009 14:54:11 +0000 |
| Subject: | note 72719 deleted from function.str-ireplace by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155684@lists.php.net to get a copy of this message | ||
Note Submitter: hans111 at yahoo dot com
----
Yet another one str_ireplace ireplacement, this one will take arrays as $search and $replace
<?php
function make_pattern(&$pat, $key) {
$pat = '/'.preg_quote($pat, '/').'/i';
}
if(!function_exists('str_ireplace')){
function str_ireplace($search, $replace, $subject){
if(is_array($search)){
array_walk($search, 'make_pattern');
}
else{
$search = '/'.preg_quote($search, '/').'/i';
}
return preg_replace($search, $replace, $subject);
}
}
?>