note 77005 deleted from function.str-replace by philip
| From: | philip@php.net | Date: | Wed, 07 Oct 2009 08:02:30 +0000 |
| Subject: | note 77005 deleted from function.str-replace by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161457@lists.php.net to get a copy of this message | ||
Note Submitter: David Gimeno i Ayuso (info at sima dot cat)
----
This is the functions I wrote for the problem reported above, str_replace in multi-dimensional
arrays. It can work with preg_replace as well.
<?php
function array_replace($SEARCH,$REPLACE,$INPUT) {
if (is_array($INPUT) and count($INPUT)<>count($INPUT,1)):
foreach($INPUT as $FAN):
$OUTPUT[]=array_replace($SEARCH,$REPLACE,$FAN);
endforeach;
else:
$OUTPUT=str_replace($SEARCH,$REPLACE,$INPUT);
endif;
return $OUTPUT;
}
?>