<?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 <h3>
<em>2. </em>[PHP]代码 </h3><pre class="brush:php;toolbar:false"><?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)!
星座活动主题卡片A5模板适用于星座活动卡片设计 本作品提供星座活动主题卡片A5模板的图片会员免费下载,格式为PSD,文件大小为69.6M; 请使用软件Photoshop进行编辑,作品中文字及图均可以通过软件修改和编辑;
php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!










