foreach循环

foreach 语句用于循环遍历数组。
每进行一次循环,当前数组元素的值就会被赋值给 value 变量(数组指针会逐一地向下移动)

1,"two"=>2,"three"=>3,"four"=>4);
foreach($array1 as $key=>$value)
{echo "KEY:$key value: $value \n";}

$array2=array(5,6,7,8);
foreach($array2 as &$value)
{
$value=$value*2;
echo "$value\n";
}

?>

结果是
1,”two”=>2,”three”=>3,”four”=>4);
foreach($array1 as $key=>$value)
{echo “KEY:$key value: $value \n”;}

$array2=array(5,6,7,8);
foreach($array2 as &$value)
{
$value=$value*2;
echo “$value\n”;
}

?>