りー
なぜこのように書くのが間違っているのですか?
このエラーは 3 行目にあります
<?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>';
はい、そうでない場合は配列を呼び出す方法
php5.4 以降を使用している場合は、次のように省略することもできます: [ ]
はい、それ以外の場合は配列を呼び出す方法
php5 を使用している場合。 4 以降、次のように省略することもできます: [ ]