From:             tomas at matfyz dot cz
Operating system: Linux
PHP version:      5.2.6
PHP Bug Type:     *General Issues
Bug description:  array_search() finds non-existent element after array_slice()!

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 bug report at http://bugs.php.net/?id=45420&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45420&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45420&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45420&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45420&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45420&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45420&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45420&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45420&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45420&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45420&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45420&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45420&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45420&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45420&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45420&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45420&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45420&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45420&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45420&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45420&r=mysqlcfg

Reply via email to