note 62849 added to function.str-replace

From: Date: Fri, 10 Mar 2006 20:09:34 +0000
Subject: note 62849 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-105239@lists.php.net to get a copy of this message
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")); ?> ---- Server IP: 217.13.201.10 Probable Submitter: 213.39.186.215 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/note/edit/62849 Del: integrated -- http://master.php.net/note/delete/62849/integrated Del: useless -- http://master.php.net/note/delete/62849/useless Del: bad code -- http://master.php.net/note/delete/62849/bad+code Del: spam -- http://master.php.net/note/delete/62849/spam Del: non-english -- http://master.php.net/note/delete/62849/non-english Del: in docs -- http://master.php.net/note/delete/62849/in+docs Del: other reasons-- http://master.php.net/note/delete/62849 Reject -- http://master.php.net/note/reject/62849 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105239) next »