菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
2505
0

星座

原创
05/13 14:22
阅读数 1998

判断今天属于哪个星座

 function constellation(){
        $month = (int)date('m');
        $day = (int)date('d');
        // 所有星座
        $constellations = [
            '摩羯座','水瓶座', '双鱼座', '白羊座', '金牛座', '双子座',
            '巨蟹座','狮子座', '处女座', '天秤座', '天蝎座', '射手座',
        ];
        //设定星座结束日期的数组,对应上面星座
        $endDays = [19, 18, 20, 20, 20, 21, 22, 22, 22, 22, 21, 21];
        if($day <= $endDays[$month - 1]){   // 当前日期 <= 该当前月份的星座结束日期 则为该星座
            $constellation = $constellations[$month - 1];
        }else{
            $constellation = empty($constellations[$month]) ? $constellations[0] : $constellations[$month];
        }
        return $constellation;
    }
php

发表评论

0/200
2505 点赞
0 评论
收藏
为你推荐 换一批