note 88091 deleted from function.str-replace by philip
| From: | philip@php.net | Date: | Wed, 07 Oct 2009 15:46:51 +0000 |
| Subject: | note 88091 deleted from function.str-replace by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161475@lists.php.net to get a copy of this message | ||
Note Submitter: php at katamari dot com dot br
----
I´ve just made gabriel dot totoliciu at ddnet dot ro's function a little smaller, hope you
like it.
NOTE: this function is not 100% secure, since the subject can have the temp replace
<?php
function stru_replace($search, $replace, $subject){
if(!is_array($search)) {
$search = array($search);
}
if(!is_array($replace)){
$replace = array($replace);
}
foreach($search as $key => $value){
//used "|{}#PHP_IsAwesome" to try make the temp replace secure, the bigger the better
$subject = str_replace($value, "|{}#PHP_IsAwesome".$key."|{}#PHP_IsAwesome",
$subject);
}
foreach($search as $key => $value){
$subject = str_replace("|{}#PHP_IsAwesome".$key."|{}#PHP_IsAwesome",
$replace[$key], $subject);
}
return($subject);
}
?>