#46365 [Com]: bug in function array_search
| From: | spambox at hshhhhh dot name | Date: | Wed, 22 Oct 2008 14:32:45 +0000 |
| Subject: | #46365 [Com]: bug in function array_search | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129984@lists.php.net to get a copy of this message | ||
ID: 46365
Comment by: spambox at hshhhhh dot name
Reported By: spabox at hshhhhh dot name
Status: Open
Bug Type: Arrays related
Operating System: winxp
PHP Version: 5.2.6
New Comment:
in array_keys() bug too
$a = array(0, 'a','a');
var_dump(array_keys($a,'a'));
#array(3) {
# [0]=>
# int(0)
# [1]=>
# int(1)
# [2]=>
# int(2)
#}
Previous Comments:
------------------------------------------------------------------------
[2008-10-22 14:28:00] spabox at hshhhhh dot name
Description:
------------
bug in function array_search:
when first element in array is zero, function return zero, but if null,
false or sth else returning correct key.
Reproduce code:
---------------
$a = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a');
var_dump($a);
var_dump(array_search('a', $a));
Expected result:
----------------
int(0)
Actual result:
--------------
int(1)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46365&edit=1