replacing a null value using str_replace

From: Date: Wed, 08 May 2002 01:15:48 +0000
Subject: replacing a null value using str_replace
Groups: php.general 
Request: Send a blank email to php-general+get-96507@lists.php.net to get a copy of this message
Hi, I was attempting to replace null values in an array with 0 using str_replace, but was unsuccessful. The values in question were coming from a MySQL query which returned an empty set. Here is what I tried: $result = str_replace('', 0, $result); Here is what I ended up doing instead (which did work): //set all null values to 0 while(list($key, $value) = each($result)) if(!$result[$key]) $result[$key] = 0; Is there any way to do this str_replace? Is there another way I should be doing this? Any insights are greatly appreciated. -- Daniel Leighton Chief Technology Officer Webolution http://www.webolution.com

« previous php.general (#96507) next »