On 27.06.2013 16:10, Christian Stoller wrote:
> Hi internals,
> 
> during my current work I had an idea for shorter array iteration with 
> foreach. I haven’t seen such a syntax until now, but I think it is easy to 
> understand ;-)
> 
> Maybe you know the case where you have to iterate over all values of a 2D (or 
> more) array:
> 
> $count = 0;
> foreach ($array as $key => $innerArray) {
>     foreach ($innerArray as $innerKey => $value) {
>         $count += $value; 
>         // and do something with $key and $innerKey
>     }
> }
> 
> 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
> }
> What do you think?

How would a break or continue on this behave? Would it end the inner or
the outer circle?


-- 
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: l...@b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to