<?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); // 双子座<?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)!
云EC电商系统(简称云EC)是由佛山市云迈电子商务有限公司自主开发的一套免费、开源的基于PHP+MYSQL电商系统软件。 云EC电商系统 1.2.1 更新日志:2018-08-10 1.修复部分环境下二维码不显示的问题; 2.商品列表增加多属性筛选支持; 3.修复更新优惠券状态时错将已使用的优惠券也更新为过期; 4.修复文章发布远程图片下载失败; 5.修复某些情况下运费计算出错导致
2595
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号