Re: Draft RFC: foreach iteration of keys without values

From: Date: Thu, 03 Sep 2020 09:18:50 +0000
Subject: Re: Draft RFC: foreach iteration of keys without values
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-111808@lists.php.net to get a copy of this message
Hi, On 03.09.20 09:58, Côme Chilliet wrote:
     foreach ($iterable as $key => $_) { ... }
I currently use foreach (array_keys($array) as $key) { ... } to avoid complains from code analysers on unused var, is it slower?
one argument brought forward initially (sorry, can't find the email right now) is the resource management: array_keys() has to create a copy [*] which might be an issue depending on the size of data. - Markus [*] I now about shallow-copy, I'm just trying to cite the initial argument as best as I can :)

« previous php.internals (#111808) next »