Answers for "php array loop"

PHP
67

php loop through array

$clothes = array("hat","shoe","shirt");
foreach ($clothes as $item) {
	echo $item;
}
Posted by: Guest on June-25-2019
1

php array loop

for ($i = 0; $i < count($array); $i++) {
    echo $array[$i]['filename'];
    echo $array[$i]['filepath'];
}
Posted by: Guest on May-05-2020
9

php iterate through array

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

foreach ($arr as $item) {
  var_dump($item);
}
Posted by: Guest on June-01-2020
1

php array loop

foreach($array as $i => $item) {
    echo $item[$i]['filename'];
    echo $item[$i]['filepath'];

    // $array[$i] is same as $item
}
Posted by: Guest on May-05-2020
13

php loop through array

foreach (array_expression as $value)
    statement
foreach (array_expression as $key => $value)
    statement
Posted by: Guest on May-26-2020
0

php array loop

foreach($array as $item) {
    echo $item['filename'];
    echo $item['filepath'];

    // to know what's in $item
    echo '<pre>'; var_dump($item);
}
Posted by: Guest on May-05-2020

Browse Popular Code Answers by Language