php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48267 new "in" keyword as an alias of array_search
Submitted: 2009-05-13 20:04 UTC Modified: 2009-05-13 22:24 UTC
From: zyss at mail dot zp dot ua Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.9 OS: Irrelevant
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: zyss at mail dot zp dot ua
New email:
PHP Version: OS:

 

 [2009-05-13 20:04 UTC] zyss at mail dot zp dot ua
Description:
------------
Please add new keyword "in" to improve readability of a PHP code that is an inline alias to array_search function.

For example:

  if (array_search($item, $array)) { ... }

would be:

  if ($item in $array) { ... }


Another example:

  if (array_search($item, array('first', 'second', 'third'))) { ... }

would be:

  if ($item in array('first', 'second', 'third')) { ... }

or ideally:

  if ($item in {'first', 'second', 'third'}) { ... }



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-13 22:24 UTC] johannes@php.net
We try to avoid adding keywords as that creates trouble with updates.

This particular feature has little benefit over the current, more verbose way.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 11:01:36 2025 UTC