Kolob Canyon Kolob Canyon - 4 months ago 12x
PHP Question

Php - Fastest method to loop through associative array keys

I only need to loop through the keys of the associative array.

Is this syntax the quickest way to do it?

foreach (arr as $key => $value) {

I'm not going to use
at all.

All I need is


If you run a static analysis with a tool like like PHP Mess Detector against that code it will report you have an unused variable.

If all you want are the keys then use array_keys() to get the keys and then loop through them.

foreach (array_keys($arr) as $key) {