Saturday, August 7, 2010

Easy birthdate dropdown

PHP Code:
/*
using
echo Birthday("22", "09", "1989");
*/
function Birthday($day="01"$month="01"$year="1980"){$rform "";$dayval range('1','31');
foreach (
$dayval as $key){
if(
$key<10){$keyadd "0$key";
}else{
$keyadd "$key";
}
if(
$day==$keyadd){$rform .= "$keyadd";
}else{
$rform .= "$keyadd";
}
}
$rform .= " ";$rform .= "";$monthval = array('1'=>'Jan''Feb''Mar''Apr''May''Jun''Jul''Aug''Sep''Oct''Nov''Dec');
foreach (
$monthval as $val => $months){
if(
$val<10){$keyadd "0$val";
}else{
$keyadd "$val";
}
if(
$month==$keyadd){$rform .= "$months";
}else{
$rform .= "$months";
}
}
$rform .= " ";$rform .= "";$yearval range('1950','2009');//you can define range year here from year -> to year
foreach ($yearval as $key){
if(
$year==$key){$rform .= "$key";
}else{
$rform .= "$key";
}
}
$rform .= "";
return 
$rform;
}  

No comments:

Post a Comment