str_replace fails with preset arrays
| From: | izx | Date: | Thu, 25 Apr 2002 06:52:22 +0000 |
| Subject: | str_replace fails with preset arrays | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-83301@lists.php.net to get a copy of this message | ||
Hi ppl,
$xarray=('ab', 'ba');
$xsearch=array('a', 'b');
$xreplace=array('c', 'd');
$xarray=str_replace($xsearch, $xreplace, $xarray);
str_replace used this way fails, returning $xarray unmodified. However:
$xarray=str_replace(array('a', 'b'), array('c', 'd'),
$xarray);
works OK.
Any solutions why str_replace doesn't work with externally defined arrays?
TIA,
izx