[PHP-BUG] Req #77532 [NEW]: foreach just over keys

[email protected] ("jerry at jmweb dot net") Mon, 28 Jan 2019 00:24:43 +0000
Newsgroups php.standards
Message-ID <[email protected]>
From:             jerry at jmweb dot net
Operating system: n/a
PHP version:      Irrelevant
Package:          PHP Language Specification
Bug Type:         Feature/Change Request
Bug description:foreach just over keys

Description:
------------
Too often I do something like:

foreach( $array as $key => $noop )
{
  // do something with $key only
}

Why not use array_keys? Well, I guess to avoid the overhead of calling a
function. It would be super if we could simply do:

foreach( $array as $key => null )
{
  // do something with $key only
}

I am not 100% set on using null, but I will let the community decide on
the specifics.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=77532&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=77532&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=77532&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=77532&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=77532&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=77532&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=77532&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=77532&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=77532&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=77532&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=77532&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=77532&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=77532&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=77532&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77532&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=77532&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=77532&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=77532&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77532&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=77532&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=77532&r=mysqlcfg