Loop through an associative array and output the key and the value. in php code example
Example 1: loop through values of hash php
foreach ($array as $key => $val) {
print "$key = $val\n";
}
Example 2: php foreach associative array
$arr = array(
'key1' => 'val1',
'key2' => 'val2',
'key3' => 'val3'
);
foreach ($arr as $key => $val) {
echo "$key => $val" . PHP_EOL;
}