Correction status:Uncorrected
Teacher's comments:
demo4.php
<?php echo '<h3>常用的数组函数(二)</h3><hr color="green">'; echo '<pre>'; $teacher = ['id'=>5, 'name'=>'peter', 'gender'=>'male', 'age'=>30]; reset($teacher); $i = 0; while($i<count($teacher)){ echo '['.key($teacher),']=>',current($teacher),'<br>'; next($teacher); $i++; } echo '<hr color="red">'; //foreach echo '<h4>讲师信息</h4>'; echo '<ul>'; foreach ($teacher as $key => $value) { echo '<li>'.$key.' : '.$value. '</li>'; } echo '</ul>'; echo '<hr color="red">'; echo '<table border="1" cellpadding="3" cellspacing="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 $value) { echo '<td align="center">'.$value.'</td>'; } echo '</tr>'; echo '</table>'; echo '<hr color="red">'; //创建一个生日选择器 echo '<p>选择你的生日</p>'; echo '<select name="years">'; $years = range(1980,2000); foreach($years as $value){ echo '<option value="'.$value.'" >'.$value.'</option>'; } echo '</select>'; echo ' '; $moths = range(1,12); echo '<select name="moths">'; foreach($moths as $value){ echo '<option value="'.$value.'" >'.$value.'</option>'; } echo '</select>'; echo ' '; $days = range(1,31); echo '<select name="days">'; foreach($days as $value){ echo '<option value="'.$value.'" >'.$value.'</option>'; } echo '</select>'; echo ' '; echo '<button>提交</button>';
点击 "运行实例" 按钮查看在线实例