<?
// пример переделан для наглядности
class dateSelector {
function makeSelector(&$string, $name, $range, $now, $values = false){
$string .= '<select name="'.$name.'">'."\n";
list($min, $max) = explode('-',$range);
for ($i = $min; $i <= $max; $i++){
$string .= "\t".'<option value="'.$i.'"';
if ($i == $now[$name]) $string .= ' selected';
$string .= '>';
if ($values) $string .= $values[$i];
else $string .= $i;
$string .= '</option>'."\n";
}
$string .= '</select>'."\n";
}
function dateSelector( &$string, $required, $timestamp = false ){
if ( !$timestamp ) $timestamp = time();
$now = getdate($timestamp);
foreach ( $required as $name => $range ){
if ( is_array($range) ){
$this->makeSelector( $string, $name, $range[0], $now, $range[1] );
} else {
$this->makeSelector( $string, $name, $range, $now );
}
}//end foreach();
}//end dateSelector();
}
$months = array(1=>"Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь");
$my_out = '';
//обращаем внимание, что select'ы можно выводить в любой последовательности
new dateSelector( $my_out,
array( 'mday'=>'1-31',
'mon'=>array('1-12', $months),
'year'=>'1999-2005',
'hours'=>'0-23',
'minutes'=>'0-59',
'seconds'=>'0-59'
)
//, $timestamp
);
echo $my_out;
?>