Re: Strange behaviour in arrays
| From: | Lars Torben Wilson | Date: | Mon, 04 Feb 2002 20:39:27 +0000 |
| Subject: | Re: Strange behaviour in arrays | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-79123@lists.php.net to get a copy of this message | ||
On Mon, 2002-02-04 at 03:41, Martin Jansen wrote:
> Taking the following script:
>
> <?php
> $array = array("foo" => true,
> "bar" => false
> );
>
> print_r($array);
> ?>
>
> The result of print_r is:
>
> Array ( [foo] => 1 [bar] => )
>
> Shouldn't false in the array definition result to 0 instead of
> nothing?
>
> - Martin
No--the string representation of boolean false is ''. You could,
I suppose, force the conversion to int in the assignment:
<?php
$array = array("foo" => true,
"bar" => (int)false);
print_r($array);
?>
Torben
> --
> Martin Jansen, <mail@martin-jansen.de>
> http://www.martin-jansen.de/
--
Torben Wilson <torben@php.net>
http://www.thebuttlesschaps.com
http://www.hybrid17.com
http://www.inflatableeye.com
+1.604.709.0506