RE: str_replace and associative arrays

From: Date: Tue, 26 Feb 2002 10:08:06 +0000
Subject: RE: str_replace and associative arrays
Groups: php.general 
Request: Send a blank email to php-general+get-86211@lists.php.net to get a copy of this message
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 (#86211) next »