星座 member.php,计算 星座 PHP

计算 星座 PHP<?php

/**

* 计算.星座

*

* @param int $month 月份

* @param int $day 日期

* @return str

*/

function get_constellation($month, $day){

$signs = array(

array('20'=>'宝瓶座'), array('19'=>'双鱼座'),

array('21'=>'白羊座'), array('20'=>'金牛座'),

array('21'=>'双子座'), array('22'=>'巨蟹座'),

array('23'=>'狮子座'), array('23'=>'处女座'),

array('23'=>'天秤座'), array('24'=>'天蝎座'),

array('22'=>'射手座'), array('22'=>'摩羯座')

);

$key = (int)$month - 1;

list($startSign, $signName) = each($signs[$key]);

if( $day < $startSign ){

$key = $month - 2 < 0 ? $month = 11 : $month -= 2;

list($startSign, $signName) = each($signs[$key]);

}

return $signName;

}

echo get_constellation(12, 11); // 射手座

echo get_constellation(6, 6); // 双子座

2.[PHP]代码<?php

/**

* 计算.星座

*

* @param int $month 月份

* @param int $date 年份

* @return str

*/

function get_constellation($month, $date){

$constellations = array(

'水瓶座', '双鱼座', '白羊座', '金牛座', '双子座', '巨蟹座',

'狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座'

);

if( $date <= 22 ){

if( 1 != $month ){

$constellation = $constellations[$month - 2];

}else{

$constellation = $constellations[11];

}

}else{

$constellation = $constellations[$month - 1];

}

return $constellation;

}

echo get_constellation(12, 11); // 射手座

echo get_constellation(6, 6); // 双子座

以上就是计算 星座 PHP的内容,更多相关内容请关注PHP中文网(www.php.cn)!

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值