<meta charset="UTF-8"/>
<?php
$year = range(1980,2020);
echo '<select name="年">';
foreach( $year as $values ){
echo '<option name="年" >'.$values.' 年</option>';
}
echo '</select>';
echo '<br>';
$month = range(1,12);
echo '<select name="月">';
foreach($month as $values){
echo '<option value="'.$values[5].'">'.sprintf("%02d",$values).'月份</option>';
}
echo '</select>';
echo '<br>';
$month = range(1,31);
echo '<select name="日">';
foreach($month as $values){
echo '<option value="'.$values.'">'.sprintf("%02d",$values).'日</option>';
}
echo '</select>';
今天学到一个函数 range();范围值,函数.
sprintf("%02d");月数不够两位数 自动前面加0
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!