时间:2021-07-01 10:21:17 帮助过:19人阅读
有两种语法:
代码如下:
foreach (array_expression as $value)
statement
foreach (array_expression as $key => $value)
statement
例子1:
代码如下:
$arr=array(1,2,3,4);
foreach($arr as $value){
echo $value."
";
}
?>
例子2:
代码如下:
$arr=array(1,2,3,4);
foreach($arr as $key=>$value){
echo $key."=====>".$value."
";
}
?>