php array foreach key value code example
Example 1: php foreach echo key value
foreach($page as $key => $value) {
echo "$key is at $value";
}
Example 2: loop through values of hash php
foreach ($array as $key => $val) {
print "$key = $val\n";
}
Example 3: foreach in php
$arr = array(
'key1' => 'val',
'key2' => 'another',
'another' => 'more stuff'
);
foreach ($arr as $key => $val){
}
foreach ($arr as $key => $val) :
endforeach;
Example 4: php foreach dict get key
foreach (iterable_expression as $key => $value)
statement