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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Apr 19 22:01:28 2024 UTC