note 71960 added to function.str-replace

From: Date: Tue, 26 Dec 2006 10:18:42 +0000
Subject: note 71960 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-120918@lists.php.net to get a copy of this message
There's a special case with str_replace which (it seems) is not documented (it is the same with preg_replace or ereg_replace). If I want to replace all occurences of " for " by " *** " (for example) in my code, I'd like to write simply : <? $str = " for for for for for for for for for "; $out = str_replace(" for ", " *** ", $str); echo $out; ?> But the answer is : *** for *** for *** for *** for *** The only way I found to get all the work done is to call the function twice, but I guess that's not the only solution for it is really ugly. ---- Server IP: 194.246.101.61 Probable Submitter: 82.254.75.84 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/71960 Del: integrated -- https://master.php.net/note/delete/71960/integrated Del: useless -- https://master.php.net/note/delete/71960/useless Del: bad code -- https://master.php.net/note/delete/71960/bad+code Del: spam -- https://master.php.net/note/delete/71960/spam Del: non-english -- https://master.php.net/note/delete/71960/non-english Del: in docs -- https://master.php.net/note/delete/71960/in+docs Del: other reasons-- https://master.php.net/note/delete/71960 Reject -- https://master.php.net/note/reject/71960 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120918) next »