php build array in 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: php loop array
<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
unset($value);
?>
Example 4: array loop function php
foreach (array_expression as $value)
statement
foreach (array_expression as $key => $value)
statement