foreach loop as key in php code example Example: loop over keys and values php foreach ($arr as $key => $value) { echo $key; }