Req #77532 [Opn]: foreach iteration over keys without values

From: Date: Mon, 28 Jan 2019 16:24:31 +0000
Subject: Req #77532 [Opn]: foreach iteration over keys without values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219252@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77532&edit=1 ID: 77532 User updated by: jerry at jmweb dot net Reported by: jerry at jmweb dot net Summary: foreach iteration over keys without values Status: Open Type: Feature/Change Request Package: Scripting Engine problem PHP Version: Irrelevant Block user comment: N Private report: N New Comment: What A fantastic RFC especially with no BC breaks! How can we get the RFC active again? I do not have experience with RFCs nor with C code so I can't verify if the patches are still compatible with the current codebase. Previous Comments: ------------------------------------------------------------------------ [2019-01-28 11:40:39] girgias@php.net There was an RFC [1] started 3 years ago which hasn't seen any activity so maybe we should look back into it? [1]: https://wiki.php.net/rfc/foreach_void ------------------------------------------------------------------------ [2019-01-28 00:53:27] jerry at jmweb dot net 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. ------------------------------------------------------------------------ [2019-01-28 00:38:42] danack@php.net > 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

« previous php.bugs (#219252) next »