Re: str_replace fails with preset arrays
| From: | Manuzhai | Date: | Thu, 25 Apr 2002 11:05:23 +0000 |
| Subject: | Re: str_replace fails with preset arrays | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-83304@lists.php.net to get a copy of this message | ||
You should probably be using strtr() for this.
Anyway, questions about developing WITH PHP should go to the php-general
list, instead of php-dev (which is for developing PHP itself).
Regards,
Manuzhai
"Izx" <izx@izx.yoll.net> wrote in message
news:20020425055241.26929.qmail@pb1.pair.com...
> 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
>
>