欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

关于二维数组。解决办法

程序员文章站 2022-06-13 15:47:35
...
关于二维数组。
	$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}
';
关于二维数组。解决办法

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频