javascript foreach
const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
console.log(index, item)
})
connect.sonveer
const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
console.log(index, item)
})
foreach ($array as $key => $val) {
print "$key = $val\n";
}
for ($i = 0; $i < count($array); $i++) {
echo $array[$i]['filename'];
echo $array[$i]['filepath'];
}
$arr = ['Item 1', 'Item 2', 'Item 3'];
foreach ($arr as $item) {
var_dump($item);
}
<?php
$arr = ['Item 1', 'Item 2', 'Item 3'];
foreach ($arr as $item) {
var_dump($item);
}
$dict = array("key1"=>"35", "key2"=>"37", "key3"=>"43");
foreach($dict as $key => $val) {
echo "$key = $val<br>";
}
?>
<?php
$array = [
[1, 2],
[3, 4],
];
foreach ($array as list($a, $b)) {
echo "A: $a; B: $b; C: $c\n";
}
?>