Req #77532 [Com]: foreach just over keys
[email protected] ("jerry at jmweb dot net") Mon, 28 Jan 2019 00:53:27 +0000
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=77532&edit=1 ID: 77532 Comment by: jerry at jmweb dot net Reported by: jerry at jmweb dot net Summary: foreach just over keys Status: Open Type: Feature/Change Request Package: PHP Language Specification Operating System: n/a PHP Version: Irrelevant Block user comment: N Private report: N New Comment: LOL. Obviously using the variable $noop works but I was hoping that the feature would 1) allow looping through keys w/out needing a variable for unused values and 2) possibly a speed bump over using array_keys. Previous Comments: ------------------------------------------------------------------------ [2019-01-28 00:38:42] [email protected] > but I will let the community decide on the specifics. How about using '$noop' ? In which case, the feature is complete. ------------------------------------------------------------------------ [2019-01-28 00:24:43] jerry at jmweb dot net 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 this bug report at https://bugs.php.net/bug.php?id=77532&edit=1