note 62849 deleted from function.str-replace by bjori
| From: | bjori@php.net | Date: | Sun, 26 Mar 2006 22:18:42 +0000 |
| Subject: | note 62849 deleted from function.str-replace by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106662@lists.php.net to get a copy of this message | ||
Note Submitter: picassodvdsmuell at gmx dot de
----
If you have, for example the string "acbd" and you want it to change into "abcd"
with two str_replaces, you would get sth like this:
accd
If you have this problem, use this code:
<?php
function str_switch($x=false,$y=false,$str=false){
if(!$x || !$y || !$str) return false;
$temp = explode($x,$str);
foreach($temp as $key => $content)
$temp2[$key] = str_replace($y,$x,$content);
return implode($y,$temp2);
}
// No comment:
echo(str_switch("D","S","YOU ALL DUCK SICK"));
?>