RE: str_replace and associative arrays

From: Date: Tue, 26 Feb 2002 11:23:01 +0000
Subject: RE: str_replace and associative arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-86224@lists.php.net to get a copy of this message
Actually, that may be part of the problem, I'm using the more recent PHP Manual on my local machine, while deving on a remote machine running 4.0.3. I had assumed the subject had always accepted and returned mixed variables in previous versions, but apparently that isn't the case. Ah well, we're upgrading tomorrow anyway. Thanks for verifying, Tim. -- mike On Tue, 26 Feb 2002, Tim Ward wrote: > >From the manual (http://www.php.net/manual/en/function.str-replace.php > <http://www.php.net/manual/en/function.str-replace.php> ) > "In PHP 4.0.5 and > later, every parameter to str_replace() can be an array. " > > I tried a test case (php 4.0.0) and found that if I passed an array in as > the subject the search and replace was performed on the string "array". > > Tim Ward > Internet chess www.chessish.com <http://www.chessish.com> > > > ---------- > From: Michael Crowl [SMTP:octopus@serv.net] > Sent: 25 February 2002 22:01 > To: php-general@lists.php.net > Subject: str_replace and associative arrays > > > I haven't been able to find any leads on this in the archives, nor > in the > documentation, so here goes. > > When feeding an associative array to str_replace as the subject, > does it > still return an associative array? > > My instance: > > extract(str_replace(",","",$result_row)); > > After pulling an associative array using mysql_fetch_array(), I can > feed > it to extract() by itself and it works as predicted and documented. > > However, if I do the above, where I want to make sure that the text > fields > (from the db) that I'm using have the commas stripped out of them, > extract() chokes with a "Warning: Bad datatype for extract()". > > I'm sure there are no commas in the key names, so those shouldn't be > altered. My only assumption is that str_replace returns array > results without keys, even though it should take and return mixed > subjects, correct? > > I may just be missing something obvious here, so have pity on a poor > soul. > You've all been there. (And one of the problems may be that I'm > working > off of PHP 4.0.3...) > > > $leepless_in_seattle(me); > > >

« previous php.general (#86224) next »