Hi.
I wanted to use in_array to verify the results of a form submission
for a checkbox and found an interesting
behaviour.
$ php -v
PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
$
$ cat in_array2.php
<?php
$node_review_types = array(
'page' => 'page',
'story' => 'story',
'nodereview' => 'abc',
);
if (in_array('page', $node_review_types)) {
print "page found in node_review_types\n";
}
if (in_array('nodereview', $node_review_types)) {
print "nodereview found in node_review_types\n";
}
?>
$ php in_array2.php
page found in node_review_types
$
This works fine. but if i change the value of the key 'nodereview' to
0 it breaks down.
$ diff in_array2.php in_array3.php
6c6
< 'nodereview' => 'abc',
---
> 'nodereview' => 0,
$
$ php in_array3.php
page found in node_review_types
nodereview found in node_review_types
$
Any reason why in_array is returning TRUE when one has a 0 value on the array ?
Thanks.
Yashesh
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php