php 根据年月获取星座

function xingZuo($month, $day){
	if ($month < 1 || $month > 12 || $day < 1 || $day > 31) 
		die('输入正确的年月');

	$constellations = [
		[ "20" => "水瓶座|1.20-2.18|1"],
		[ "19" => "双鱼座|2.19-3.20|2"],
		[ "21" => "白羊座|3.21-4.19|3"],
		[ "20" => "金牛座|4.20-5.20|4"],
		[ "21" => "双子座|5.21-6.21|5"],
		[ "22" => "巨蟹座|6.22-7.22|6"],
		[ "23" => "狮子座|7.23-8.22|7"],
		[ "23" => "处女座|8.23-9.22|8"],
		[ "23" => "天秤座|9.23-10.23|9"],
		[ "24" => "天蝎座|10.24-11.22|10"],
		[ "23" => "射手座|11.23-12.21|11"],
		[ "22" => "摩羯座|12.22-1.19|12"]
	];	
	 list($constellation_start, $constellation_name) = each($constellations[(int)$month-1]);
	if ($day < $constellation_start){
	 	list($constellation_start, $constellation_name) = each($constellations[($month -2 < 0) ? $month = 11: $month -= 2]);
	}
	$constellation = $constellation_name;
	return $constellation;
}

 

转载于:https://my.oschina.net/lnmpstudy/blog/788343

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值