Re: New syntax for multidimensional array loop with foreach
| From: | Nikita Popov | Date: | Thu, 27 Jun 2013 14:58:13 +0000 |
| Subject: | Re: New syntax for multidimensional array loop with foreach | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67955@lists.php.net to get a copy of this message | ||
On Thu, Jun 27, 2013 at 4:10 PM, Christian Stoller <stoller@leonex.de>wrote:
> The new syntax could make it shorter and faster to write... but maybe it's
> a bit too confusing?
>
> $count = 0;
> foreach ($array as $key => $innerArray as $innerKey => $value) {
> $count += $value;
> // and do something with $key and $innerKey
> }
>
I'm against this feature. It makes the code marginally shorter, but a good
bit less readable. Combined with the break/continue issue, I don't think we
gain anything by introducing this syntax.
Nikita