note 52015 deleted from function.str-ireplace by aidan
| From: | aidan@php.net | Date: | Sun, 24 Jul 2005 04:17:45 +0000 |
| Subject: | note 52015 deleted from function.str-ireplace by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92364@lists.php.net to get a copy of this message | ||
Note Submitter: Andrew Cassidy andee at bytz co uk
----
Here is another str_ireplace for PHP4 that accepts arrays as input variables. I also found it easier
to follow than the previously mentioned one, which is probably more efficient thatn this method:
<?php
function str_Ireplace($search, $replace, $subject) {
if (is_array($search)) {
foreach ($search as $word) {
$words[] = "/".$word."/i";
}
}
else {
$words = "/".$search."/i";
}
return preg_replace($words, $replace, $subject);
}
?>