how to store values in array in php using for loop code example
Example 1: php array loop
foreach($array as $i => $item) {
echo $item[$i]['filename'];
echo $item[$i]['filepath'];
}
Example 2: php array loop
for ($i = 0; $i < count($array); $i++) {
echo $array[$i]['filename'];
echo $array[$i]['filepath'];
}
Example 3: loop through php array
foreach (array_expression as $value)
statement
foreach (array_expression as $key => $value)
statement
Example 4: loop array in php
<?php
$colors = array("red", "green", "blue", "yellow");
foreach ($colors as $value) {
echo "$value <br>";
}
?>