ID: 45420
Comment by: florian dot ember at gmail dot com
Reported By: tomas at matfyz dot cz
Status: Open
Bug Type: *General Issues
Operating System: Linux
PHP Version: 5.2.6
New Comment:
> array(1) {
> [0]=>
> int(0)
> }
0 == 'any non-numeric string'
Previous Comments:
------------------------------------------------------------------------
[2008-07-02 18:34:54] tomas at matfyz dot cz
Description:
------------
array_search() function finds non-existent element after array_slice()
is used to slice the array.
tested on 5.2.0 and 5.2.5, don't have access to newer system.
Reproduce code:
---------------
$a["nazdar"] = "pozdrav";
$a["write"] = 1;
$a[2] = "ahoj";
$a = array_slice($a, 2);
$keys = array_keys($a);
echo "keys:\n"; var_dump($keys);
check_array_search("wrqwdite2", $keys);
function check_array_search($val, $keys)
{
$i = array_search($val, $keys);
if ($i === false) {
echo "OK\n";
return;
}
echo "BUG!!! Non-existent value \"$val\" found in keys at
position $i!!!\n";
}
Expected result:
----------------
keys:
array(1) {
[0]=>
int(0)
}
OK
Actual result:
--------------
keys:
array(1) {
[0]=>
int(0)
}
BUG!!! Non-existent value "wrqwdite2" found in keys at position 0!!!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45420&edit=1