Re: replacing a null value using str_replace
| From: | CC Zona | Date: | Wed, 08 May 2002 06:22:58 +0000 |
| Subject: | Re: replacing a null value using str_replace | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96534@lists.php.net to get a copy of this message | ||
In article <p05100310b8fe2b3decbb@[192.168.1.103]>,
daniel@webolution.com (Daniel Leighton) wrote:
> 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.
FWIW, you can do these replacements in the query itself. The syntax may be
slightly off here because I'm overtired, but it should be something like:
select if(isnull(fieldname),0,fieldname) as fieldname from ....
See the MySQL manual for more info.
--
CC