On Mon, Aug 31, 2020 at 11:53 PM Michael Voříšek - ČVUT FEL < [email protected]> wrote:
> Optimizing foreach (array_keys($arr) as $k) is very important, not only
> because of memory, but because of speed when not all elements needs to
> be iterated, like:
>
> foreach (array_keys($arr) as $k) {
>
> if ($k some condition) {
>
> break;
>
> }
>
> }
>
Can an iterator be the answer? E.g.
foreach (new ArrayKeysIterator($arr) as $k) { ... }
--
Best regards,
Max Semenik
