Re: Proposed additional behaviour of str_replace()
| From: | Yasuo Ohgaki | Date: | Fri, 19 Apr 2002 04:58:12 +0000 |
| Subject: | Re: Proposed additional behaviour of str_replace() | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-82993@lists.php.net to get a copy of this message | ||
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)); ?>-1 uless multibyte char keys are handled well. Currently, multibyte char does not work well as hash key. Fixing this is not simpile. -- Yasuo Ohgaki