Re: New feature: additional syntax proposal for Foreach

From: Date: Wed, 03 Jul 2013 20:07:11 +0000
Subject: Re: New feature: additional syntax proposal for Foreach
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-68059@lists.php.net to get a copy of this message
Welcome Chris, As a plain user of PHP, i'd like to advocate not to allow anymore aliasing of ways to do stuff... Your example should just read foreach(array_keys($array) as $key) {} That's the only way to convey the actual intent of working with keys and explicitly leaving out the values ;) But hey, just my 2c... Met vriendelijke groet, Robin Speekenbrink Kingsquare BV 2013/7/3 Chris London <me@chrislondon.co> > Hello community, > > This is my first post here. I hope to improve my participation in the > community and give back to the technology that has done so much for my > career. My first attempt is to propose an additional syntax for the > Foreach statement. > > Background: > > There are times in our code where we can leave things blank that we don't > need, such as: > > for ( ; ; ) { > > } > > - and - > > list( , $foo, $bar) = array('ignore', 'myFoo', 'myBar'); > > Proposal: > > I have found over the years that there are times when I want to loop > through an associative array but I don't need the value. I would like to > allow the following syntax: > > foreach ($array as $key => ) { > > } > > Please let me know your thoughts. > > Thanks > Chris London >

« previous php.internals (#68059) next »