
php语法如何通过输入月份和日期获取个人星座,下面web建站小编给大家简单介绍一下具体实现方法!
示列代码:
function getConstellation($month, $day){
if(($month < 1 || $month > 12) || ($day < 1 || $day > 31)) return false;
$constellations = [
['20' => '水瓶座'], ['19' => '双鱼座'], ['21' => '白羊座'], ['20' => '金牛座'],
['21' => '双子座'], ['22' => '巨蟹座'], ['23' => '狮子座'], ['23' => '处女座'],
['23' => '天秤座'], ['24' => '天蝎座'], ['22' => '射手座'], ['22' => '魔羯座']
];
list($constellation_key, $constellation_value) = each($constellations[(int)$month - 1]);
if($day < $constellation_key){
list($constellation_key, $constellation_value) =
each($constellations[($month - 2 < 0) ? $month = 11 : $month -= 2]);
}
return $constellation_value;
}
echo getConstellation(5,12);
echo getConstellation(1,6);
php删除接口:在指定的数据库数据表中根据ID删除指定的数据
上面是“php如何通过出生月份日期来计算星座”的全面内容,想了解更多关于 php入门 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4538.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

uniapp语法如何禁止view手动滑动
录咖APP最新版
2345天气预报
好消息:vue3中文文档上线了!
文章标题长度影响排名吗?