php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #9337 make in_array return key, if searched value was found
Submitted: 2001-02-19 11:18 UTC Modified: 2001-02-20 19:02 UTC
From: sbergmann@php.net Assigned: jason (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.4pl1 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sbergmann@php.net
New email:
PHP Version: OS:

 

 [2001-02-19 11:18 UTC] sbergmann@php.net
in_array() currently returns only true/false on whether or not a searched-for value is in a given array.

I would like it to return the key of the array's element when value was found, and false otherwise. This should not break existing code using in_array().

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-19 12:18 UTC] andre@php.net
maybe a fourth parameter switch to avoid 0->false problems?
 [2001-02-19 13:12 UTC] jason@php.net
Andrei and I descussed the possibility of creating a new function. I will explore this.

-Jason
 [2001-02-20 19:02 UTC] jason@php.net
Request complete, new function created called array_search in CVS. Check it out in snapshots.

-Jason

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC