Proposed additional behaviour of str_replace()
| From: | Mårten Gustafsson | Date: | Tue, 16 Apr 2002 23:01:29 +0000 |
| Subject: | Proposed additional behaviour of str_replace() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-82868@lists.php.net to get a copy of this message | ||
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));
?>
regards,
Marten.