"10","sex"=>"nan"), ("name"=>"zs","age"=>"10","sex"=>"nan"), ("name"=>"zs","age">
当前位置:Gxlcms > PHP教程 > 关于二维数组。解决办法

关于二维数组。解决办法

时间:2021-07-01 10:21:17 帮助过:16人阅读

关于二维数组。
	$group1 = array(
("name"=>"zs","age"=>"10","sex"=>"nan"),
("name"=>"zs","age"=>"10","sex"=>"nan"),
("name"=>"zs","age"=>"10","sex"=>"nan"),
("name"=>"ls","age"=>"11","sex"=>"nan"),
("name"=>"ww","age"=>"12","sex"=>"nv"),
("name"=>"ls","age"=>"11","sex"=>"nan"),
("name"=>"ww","age"=>"12","sex"=>"nv"),
("name"=>"ls","age"=>"11","sex"=>"nan"),
("name"=>"ww","age"=>"12","sex"=>"nv")
);

echo '';
echo '';
foreach( $row as $col ){
echo '';
}
echo '';
}
echo '

数组转化为表格

';

foreach( $group as $row ){
echo '
{$col}
';
?>


这样写为何不对?
------解决方案--------------------
	$group = array(
array("name"=>"zs","age"=>"10","sex"=>"nan"),
array("name"=>"zs","age"=>"10","sex"=>"nan"),
array("name"=>"zs","age"=>"10","sex"=>"nan"),
array("name"=>"ls","age"=>"11","sex"=>"nan"),
array("name"=>"ww","age"=>"12","sex"=>"nv"),
array("name"=>"ls","age"=>"11","sex"=>"nan"),
array("name"=>"ww","age"=>"12","sex"=>"nv"),
array("name"=>"ls","age"=>"11","sex"=>"nan"),
array("name"=>"ww","age"=>"12","sex"=>"nv")
);

echo '';
echo '';
foreach( $row as $col ){
echo "";
}
echo '';
}
echo '

数组转化为表格

';

foreach( $group as $row ){
echo '
{$col}
';

人气教程排行