Re: Re: replacing a null value using str_replace
| From: | Daniel Leighton | Date: | Wed, 08 May 2002 17:17:57 +0000 |
| Subject: | Re: Re: replacing a null value using str_replace | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96607@lists.php.net to get a copy of this message | ||
Hi Dan - It looked good and I tried it, but it still didn't work.
Adam - to answer your questions it is an array and the while code does work.
Any other ideas? I can stick with the while loop, I'm just curious if I can do it with
str_replace and if that would be faster.
Thank you both for your replies.
Daniel
At 9:49 AM +0100 on 5/8/02, Dan Hardiker 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.
>
>If your using string replace functions, then use chr(0) - which is the null
>byte.
>
>>> $result = str_replace('', 0, $result);
>
>Try: $result = str_replace(chr(0), 0, $result);
>
>--
>Dan Hardiker [dhardiker@staff.firstcreative.net]
>ADAM Software & Systems Engineer
>First Creative Ltd
--
Daniel Leighton
Chief Technology Officer
Webolution
http://www.webolution.com