php 遍曆二維數組與多維陣列代碼關於php的數組,我們來講一下,二維數組與多維的遍曆代碼,下面舉了三個執行個體來測試數組的遍曆php代碼函數了。
php教程 遍曆二維數組與多維陣列代碼
關於php的數組,我們來講一下,二維數組與多維的遍曆代碼,下面舉了三個執行個體來測試數組的遍曆php代碼函數了。
*/
function arr_foreach ($arr) {
if (!is_array ($arr)) {
return false;
}
foreach ($arr as $key => $val ) {
if (is_array ($val)) {
arr_foreach ($val);
} else {
echo $val.'
';
}
}
}
$arr1 = array (1=>array(11,12,13,14=>array(141,142)),2,3,4,5);
arr_foreach ($arr1);
//php遍曆多維陣列
$array = array('a'=>"'as","b"=>array('c'=>"'cc","n"=>array('1'=>"'sdf")),'f'=>array('c'=>"'sdf","g"=>array("c")));
function handleeach(&$array,$functionname)
{
foreach($array as $k=>$v)
{
if(is_array($v))
{
handleeach(&$array[$k],$functionname);
}
else
$array[$k] = $functionname($v);
}
}
handleeach($array,'strips教程lashes');
print_r($array);
//執行個體三,遍曆二維數組
$employee[]=array("jas,join",");
$employee[]=array("june,join","programmer",20);
$employee[]=array("aili,join","programmer",20);
$employee[]=array("doe,jane","programmer",20);
$newname = array();
foreach ($employee as $record){
$newname[] = isset($record[0]) ? $record[0] : 'no name';
}
?>
http://www.bkjia.com/PHPjc/445432.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445432.htmlTechArticlephp 遍曆二維數組與多維陣列代碼關於php的數組,我們來講一下,二維數組與多維的遍曆代碼,下面舉了三個執行個體來測試數組的遍曆php代碼函...