Copy code The code is as follows:
//Use a for loop to traverse
$arr2=array(array("Zhang San","20","Male"),array("李四","25","Male"),array("王五","19 ","Female"),array("Zhao Liu","25","Female"));
echo "
Name< /td> | Age | Gender
";
for($i=0;$i<4;$i++){
echo "";
for($j=0;$j<3;$j++){
echo ""; echo $arr2[$i ][$j]; echo " | ";
}
echo "
";
echo "
";
}
echo "
";
?>
//Use foreach to traverse
Copy Code The code is as follows:
$arr = array('one'=>array('name'=>'Zhang San', 'age'=>'23','sex'=>'Male'),
'two'=>array('name'=>'李思','age'=>' 43','sex'=>'female'),
'three'=>array('name'=>'王五','age'=>'32','sex'= >'Male'),
'four'=>array('name'=>'Zhao Liu','age'=>'12','sex'=>'Female')) ;
foreach($arr as $k=>$val){
echo $val['name'].$val['age'].$val['sex']."
";
}
echo "
";
?>
Copy code Code As follows:
$arr = array('one'=>array('name'=>'Zhang San','age'=>'23 ','sex'=>'Male'),
'two'=>array('name'=>'李思','age'=>'43','sex'=> ;'Female'),
'three'=>array('name'=>'王五','age'=>'32','sex'=>'Male'),
'four'=>array('name'=>'Zhao Liu','age'=>'12','sex'=>'female'));
foreach($arr as $key=>$value){
foreach($value as $key2=>$value2){
echo $value2;
}
echo "
";
}
?>
http://www.bkjia.com/PHPjc/327480.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327480.htmlTechArticleCopy the code as follows: ?php //Use a for loop to traverse $arr2=array(array("Zhang San" ,"20","male"),array("李思","25","male"),array("王五","19","female"),array("Zhao Liu"," 25","female")); ec...