Re: Proposed additional behaviour of str_replace()

From: Date: Wed, 17 Apr 2002 06:54:44 +0000
Subject: Re: Proposed additional behaviour of str_replace()
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-82881@lists.php.net to get a copy of this message
On Wed, Apr 17, 2002 at 01:01:29AM +0200, Mårten Gustafsson wrote : > Is there anyone else than me that would find it useful to be able to do: > > <?php > $string = 'foo bar'; > $replacements = array( > 'foo' => 'FOO', > 'bar' => 'BAR'); > // Prints "FOO BAR" > echo str_replace($replacements, $string); > ?> > > With current behaviour one has to do: > > <?php > $string = 'foo bar'; > $replacements = array( > 'foo' => 'FOO', > 'bar' => 'BAR'); > // Prints "FOO BAR" > echo str_replace(array_keys($replacements), array_values($string)); > ?> The syntax is str_replace(search, replace, subject), btw. Personally, I don't see a need for this. On the other side, if it gets done, think about BC. -- Please always Cc to me when replying to me on the lists. GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc "Mind if I MFH ?" "What QA did you do on it?" "the usual?" "ah... none :)"

« previous php.dev (#82881) next »