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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 10:01:32 2024 UTC