I tested this in bash.
Compare these two functions. In the first, I am creating an array with integer indexes, in the second an associative array. I got the expected results in bash. I'm not sure which variant of shell you are using, so I don't know whether you need to add the declaration or quote the array keys or both.
x ()
{
declare -a test_array;
test_array=([a]=10 [b]=20 [c]=30);
for k in "${!test_array[@]}";
do
printf "%s\n";
echo "$k=${test_array[$k]}";
done
}
y
y ()
{
declare -A test_array;
test_array=(["a"]=10 ["b"]=20 ["c"]=30);
for k in "${!test_array[@]}";
do
printf "%s\n";
echo "$k=${test_array[$k]}";
done
}
x