实例
<?php $teacher = ['id'=>1001,'name'=>'peter','salary'=>1000,'course'=>'php']; for($i=0;$i<count($teacher);$i++){ echo '['.key($teacher).']=>'.current($teacher).'<br>'; next($teacher); } echo '<hr color="red">'; reset($teacher); $i=0; while($i<count($teacher)){ echo '['.key($teacher).']=>'.current($teacher).'<br>'; next($teacher); $i++; } echo '<hr color="blue">'; reset($teacher); foreach($teacher as $key => $value){ echo '['.$key.']=>'.$value.'<br/>'; } $year = range(1980,2000); echo '<select name="year">'; foreach($year as $v){ echo '<option>'.$v.'</option>'; } echo '</select>'; $months = range(1,12); echo '<select name="months">'; foreach($months as $v){ echo '<option>'.sprintf("%02d",$v).'</option>'; } echo '</select>'; $days = range(1,30); echo '<select name="days">'; foreach($days as $v){ echo '<option>'.$v.'</option>'; } echo '</select>';
运行实例 »
点击 "运行实例" 按钮查看在线实例