In PHP, is there a way to iterate over only the keys of an array, not the values?

For example, I'm currently doing this:

  foreach ($ myArray as $ key => $ unused) {
     // use $ key here
 } 

Is there a way to do this without specifying $ unused value?

+4
source share
1 answer
<?php foreach(array_keys($myArray) as $key) {} 

API

+8
source

All Articles