/**
* 根据生日中的月份和日期来计算所属 星座
*
* @param int $birth_month //9
* @param int $birth_date //1
*
* @return string
*/
public 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;
}
根据生日中的月份和日期来计算所属 星座
最新推荐文章于 2023-09-04 00:20:47 发布