note 88091 added to function.str-replace
| From: | php at katamari dot com dot br | Date: | Fri, 09 Jan 2009 18:27:32 +0000 |
| Subject: | note 88091 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148997@lists.php.net to get a copy of this message | ||
TO: gabriel dot totoliciu at ddnet dot ro
I´ve just made your function a little smaller, hope you like it.
NOTE: this function is not 100% secure, since the subject can have the temp replace
<?
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);
}
?>
----
Server IP: 200.185.126.110
Probable Submitter: 189.120.154.57
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/88091
Del: integrated -- https://master.php.net/note/delete/88091/integrated
Del: useless -- https://master.php.net/note/delete/88091/useless
Del: bad code -- https://master.php.net/note/delete/88091/bad+code
Del: spam -- https://master.php.net/note/delete/88091/spam
Del: non-english -- https://master.php.net/note/delete/88091/non-english
Del: in docs -- https://master.php.net/note/delete/88091/in+docs
Del: other reasons-- https://master.php.net/note/delete/88091
Reject -- https://master.php.net/note/reject/88091
Search -- https://master.php.net/manage/user-notes.php