<?php $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 '<table border="1" width="800" align>'; echo '<caption><h1>数组转化为表格</h1><caption>'; foreach( $group as $row ){ echo '<tr>'; foreach( $row as $col ){ echo '<td>{$col}</td>'; } echo '</tr>'; } echo '</table>';?>
这个错在第三行
$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 '<table border="1" width="800" align>'; echo '<caption><h1>数组转化为表格</h1><caption>'; foreach( $group as $row ){ echo '<tr>'; foreach( $row as $col ){ echo "<td>{$col}</td>"; } echo '</tr>'; } echo '</table>';
$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 '<table border="1" width="800" align>'; echo '<caption><h1>数组转化为表格</h1><caption>'; foreach( $group as $row ){ echo '<tr>'; foreach( $row as $col ){ echo "<td>{$col}</td>"; } echo '</tr>'; } echo '</table>';
是的,不然怎么叫数组
如果你是在 php5.4 及以上,也可简写为:[ ]
是的,不然怎么叫数组
如果你是在 php5.4 及以上,也可简写为:[ ]