PHP foreach loop
foreach loop through the array is used.
grammar
foreach ($array as $value)
{
要执行代码;
}
Once every cycle, the current value of the array elements will be assigned to the variable $ value (array pointer is moved one by one.
Examples
<?php $x=array("one","two","three"); foreach ($x as $key=>$value) {
echo $key.'-'.$value . "<br>";
}
?>
//输出
1-one
2-two
3-three