php iterate through array
snippet in php

php loop through array

user564

$clothes = array("hat","shoe","shirt");
foreach ($clothes as $item) {
	echo $item;
}

php loop troug array

user7016

<?php
$salary[]=2000;
$salary[]=3000;
$salary[]=5000;

foreach($salary as $value){
  echo "Salary: $value<br>";
}
?>

php iterate through array

user3225

$arr = ['Item 1', 'Item 2', 'Item 3'];

foreach ($arr as $item) {
  var_dump($item);
}

how to iterate through php array

user3964

$ar = ['Rudi', 'Morie', 'Halo', 'Miki'];

for ($i=0, $len=count($ar); $i<$len; $i++) {
    echo "$ar[$i] \n";
}
/*
Rudi 
Morie 
Halo 
Miki 
*/

foreach in php

user1463

<?php
// Declare an array 
$arr = array("green", "blue", "pink", "white");  
  
// Loop through the array elements 
foreach ($arr as $element) { 
    echo "$element "; 
} 
?>

loop through php array

user5942

foreach (array_expression as $value)
    statement
foreach (array_expression as $key => $value)
    statement