foreach php
snippet in php

php loop through array

user9439

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

php foreach

user9537

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

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

forreah php

user7769

$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
    $value = $value * 2;
}

javascript foreach

user7541

const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
	console.log(index, item)
})

foreach php

user8043

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

foreach php

user6707


<?php 
$colors = array("red", "green", "blue", "yellow"); 

 
foreach ($colors as $value) {
  echo "$value <br>";
}
?>