Bug #64129 [Opn->Nab]: bug in in_array
| From: | rasmus@php.net | Date: | Fri, 01 Feb 2013 19:17:36 +0000 |
| Subject: | Bug #64129 [Opn->Nab]: bug in in_array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-176392@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64129&edit=1
ID: 64129
Updated by: rasmus@php.net
Reported by: email dot fivemin at gmail dot com
Summary: bug in in_array
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: All
PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
You want:
in_array(0,$v,true);
then. The code is behaving correctly because you are doing a non-strict search
and you have and empty element which will match 0 with a non-strict match.
Previous Comments:
------------------------------------------------------------------------
[2013-02-01 19:10:23] email dot fivemin at gmail dot com
edit
------------------------------------------------------------------------
[2013-02-01 19:05:11] email dot fivemin at gmail dot com
Description:
------------
this code return 1
i have null member and null isn't zero!
<?
$t="1,2,";
$v=explode(",",$t);
print_r($v);
echo in_array(0,$v);
echo "\n";
?>
Test script:
---------------
<?
$t="1,2,";
$v=explode(",",$t);
print_r($v);
echo in_array(0,$v);
echo "\n";
?>
Expected result:
----------------
in_array function return 0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64129&edit=1