note 71960 deleted from function.str-replace by nlopess
| From: | nlopess@php.net | Date: | Tue, 26 Dec 2006 11:27:19 +0000 |
| Subject: | note 71960 deleted from function.str-replace by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-120923@lists.php.net to get a copy of this message | ||
Note Submitter: tastalian at gmail dot com
----
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.