ID:               45420
 User updated by:  tomas at matfyz dot cz
 Reported By:      tomas at matfyz dot cz
 Status:           Bogus
 Bug Type:         *General Issues
 Operating System: Linux
 PHP Version:      5.2.6
 New Comment:

I See.

What I dislike on PHP is that it is ABSOLUTELY CONTRA-INTUITIVE. I know
many computer languages but none of them finds zero when I look for
"search string".


Previous Comments:
------------------------------------------------------------------------

[2008-07-11 18:43:31] [EMAIL PROTECTED]

Do use the third parameter.

http://docs.php.net/array-search

------------------------------------------------------------------------

[2008-07-03 16:35:34] tomas at matfyz dot cz

> 0 == 'any non-numeric string'

Yeees, but how is this related to array_search()? In no way, I believe.
Or at least, shouldn't be.

------------------------------------------------------------------------

[2008-07-03 12:50:16] florian dot ember at gmail dot com

> array(1) {
>   [0]=>
>   int(0)
> }

0 == 'any non-numeric string'

------------------------------------------------------------------------

[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

Reply via email to