php loop through array number and get that arrays key values code example
Example 1: php loop through array
$clothes = array("hat","shoe","shirt");
foreach ($clothes as $item) {
echo $item;
}
Example 2: loop through values of hash php
foreach ($array as $key => $val) {
print "$key = $val\n";
}
Example 3: create pair foreach item in array
arr = [1, 2, 3, 4];
function pairwise(arr, func){
for(var i=0; i < arr.length - 1; i++){
func(arr[i], arr[i + 1])
}
}
pairwise(arr, function(current, next){
console.log(current, next)
})