<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>无限数组遍历</title>
</head>
<body>
<?php
//生成从1到100的数组的值
$arr=array();
echo "<pre>";
//按原格式显示
for ($i=0;$i<=99;$i++){
$arr[$i]=($i+1);
}
print_r($arr);
echo "</pre>";
//无限遍历数组
$a1=array("a","b","c"); //一维数组
$a2=array(array(21,3,6),array("a","b","c"));
//二维数组
$a3=array(array(array(5,55),4,444),2,7,6,8,array("w","d",array(3,2,"a"),"s"));
//多维不规则数组
function fun($a){
foreach($a as $val){
if (is_array($val)){ //如果键值是数组,则进行函数递归调用
fun($val);
}
else{ // 如果键值是数值,则进行输出
echo
"$val<br />";
} //end
if
} //end foreach
} //end fun
fun($a3);
?>
</body>
</html>