项目中经常会用到年份选择,这段代码自动生成从今年开始的过去100年的下拉列表
<select name="year"> <?php $years = range(date("Y"), date("Y", strtotime("now - 100 years"))); foreach($years as $year){ echo'<option value="'.$year.'">'.$year.'</option>'; } ?> </select>
项目中经常会用到年份选择,这段代码自动生成从今年开始的过去100年的下拉列表
<select name="year"> <?php $years = range(date("Y"), date("Y", strtotime("now - 100 years"))); foreach($years as $year){ echo'<option value="'.$year.'">'.$year.'</option>'; } ?> </select>