How to loop through an associative array and get the key? [duplicate]

You can do:

foreach ($arr as $key => $value) {
 echo $key;
}

As described in PHP docs.

Leave a Comment