Correction status:Uncorrected
Teacher's comments:
<?php echo '<h3>数组的遍历</h3><hr color="green">'; $teacher=['id'=>10086,'name'=>'liangxiansheng','salary'=>300,'course'=>'php']; // 用for来实现关联数组的遍历 for($i=0; $i<count($teacher);$i++){ echo '['.key($teacher),']=>',current($teacher),'<br>'; next($teacher); } echo '<hr>'; // while()循环 reset($teacher); $i=0; while ($i<count($teacher)) { echo '['.key($teacher),']=>',current($teacher),'<br>'; next($teacher);//循环体 $i++;//条件更新 } echo '<hr>'; // foreach($arr os [$key=>]$value){}数组遍历专用 echo '<h3>学生信息</h3>'; echo '<ul>'; foreach ($teacher as $key => $value) { echo '<li>'.$key.':'.$value.'</li>'; } echo '</ul>'; echo '<hr color="green">'; echo '<table border="1" cellpadding="3" cellspacin="0" width="300">'; echo '<caption>学员信息表</caption>'; echo '<tr bgcolor=lightskyblue><th>ID</th><th>姓名</th><th>学费</th><th>课程</th><tr>'; echo '<tr>'; foreach ($teacher as $key => $value) { echo '<td align="center">'.$value.'</td>'; } echo '</tr>'; echo '</table>'; // 创建一个生日选择器 echo '<p>选择你的生日</p>'; $years=range(1950,2000);//生成指定范围的一个数组 年 echo '<select name="year">'; foreach ($years as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; } echo '</select>'; echo ' '; $months=range(1,12);//生成指定范围的一个数组 月 echo '<select name="year">'; foreach ($months as $value) { echo '<option value="'.$value.'">'.sprintf("%02d",$value).'</option>'; } echo '</select>'; echo ' '; $days=range(1,31);//生成指定范围的一个数组 日 echo '<select name="year">'; foreach ($days as $value) { echo '<option value="'.$value.'">'.sprintf("%02d",$value).'</option>'; } echo '</select>'; echo ' '; echo ' '; echo '<button>提交</button>';
点击 "运行实例" 按钮查看在线实例