for array in php code example
Example 1: php array loop
foreach($array as $i => $item) {
echo $item[$i]['filename'];
echo $item[$i]['filepath'];
// $array[$i] is same as $item
}
Example 2: php array loop
for ($i = 0; $i < count($array); $i++) {
echo $array[$i]['filename'];
echo $array[$i]['filepath'];
}
Example 3: loop array in php
<?php
$colors = array("red", "green", "blue", "yellow");
foreach ($colors as $value) {
echo "$value <br>";
}
?>