[fOnt=Arial]
[fOnt=Arial]/**
* 根据生日中的月份和日期来计算所属星座
*
* @param int $birth_month
* @param int $birth_date
* @return string
*/
function get_constellation($birth_month,$birth_date)
{
//判断的时候,为避免出现1和true的疑惑,或是判断语句始终为真的问题,这里统一处理成字符串形式
$birth_mOnth= strval($birth_month);
$constellation_name = array(
'水瓶座','双鱼座','白羊座','金牛座','双子座','巨蟹座',
'狮子座','处女座','天秤座','天蝎座)','射手座','摩羯座'
);
if ($birth_date <= 22)
{
if ('1' !== $birth_month)
{
$cOnstellation= $constellation_name[$birth_month-2];
}
else
{
$cOnstellation= $constellation_name[11];
}
}
else
{
$cOnstellation= $constellation_name[$birth_month-1];
}
return $constellation;
}[/font]
[fOnt=Arial]/**
* 根据生日中的年份来计算所属生肖
*
* @param int $birth_year
* @return string
*/
function get_animal($birth_year)
{
//1900年是子鼠年
$animal = array(
'子鼠','丑牛','寅虎','卯兔','辰龙','巳蛇',
'午马','未羊','申猴','酉鸡','戌狗','亥猪'
);
$my_animal = ($birth_year-1900)%12;
return $animal[$my_animal];
}[/font]
|