
Jennifer H. answered 03/27/20
Tutor
5
(65)
Professional web developer
Yes, you can know the array keys by doing a foreach loop like this:
$my_array = ['a' => 1, 'b' => 2];
foreach ($my_array as $key => $value) {
echo "Array key is " . $key . "\n";
}
This will work with numeric array keys as well.