php中(foreach)用法介绍
foreach ($array as $key => $value)
foreach 仅能用于数组,每次循环中,当前单元的键名也会在每次循环中被赋给变量 $key。当前单元的值被赋给 $value 并且数组内部的指针向前移一步。
$arr=array(0=>"你好",1=>"世界",2=>"朋友");
//var_dump($arr);
foreach ($arr as $key=>$vol){
echo "这个是键值对".$key."的结果----".$vol."
";
}
?>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn