> 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.
Of course :) > Personally, I don't see a need for this. On the other side, > if it gets done, think about BC. My point, which was not clear, was the ablity to provide one array with all needles and replacements. And yep, it would have to be a new function to preserve BC...but since I´m, obviously, blind I havn´t noticed that strtr() does exactly what I asked for :) Marten. -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php