php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20765 problem with array_search function
Submitted: 2002-12-02 11:10 UTC Modified: 2002-12-02 11:21 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: lenny at solbridge dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.2.3 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lenny at solbridge dot com
New email:
PHP Version: OS:

 

 [2002-12-02 11:10 UTC] lenny at solbridge dot com
array_search will return "THE POSITION of the NEEDLE" when a needle is found in an array and return "FALSE" when not found.   The problem will occur when the NEEDLE is found to be at the first position of an array which will return a "0", a value that is equipvalent to "FALSE" though the NEEDLE has been successfully found. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-02 11:21 UTC] philip@php.net
There is a warning in the docs, I'll quote it here:

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.

This comes from the &return.falseproblem; entity in the docs.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 14:01:27 2024 UTC