|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16146 array_search always skips first element of array
Submitted: 2002-03-18 10:23 UTC Modified: 2002-03-18 10:28 UTC
From: carl at bodgadle dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.6 OS: Solaris
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: carl at bodgadle dot com
New email:
PHP Version: OS:


 [2002-03-18 10:23 UTC] carl at bodgadle dot com
I think i've discovered a problem with array_search. If I have an array, say

$arr = Array("one","two","a");

then I try

$retVal = array_search("one",$arr);

it will return false, however the other two elements are fine.

It seems array_search just ignores the first element in the array, I can search the rest of the array fine, just not the first element. If I put another item at the start I can find "one" fine.

in_array works fine, it's just array_search that fails


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-18 10:28 UTC]
From the manual (

array_search --   Searches the array for a given value and returns the
                  corresponding key if successful


   This  function  may  return  Boolean  FALSE,  but  may  also  return a
   non-Boolean  value  which  evaluates to FALSE, such as 0 or "". Please
   read  the  section  on  Booleans  for  more  information.  Use the ===
   operator for testing the return value of this function.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 28 17:03:37 2021 UTC