Home > Backend Development > PHP Tutorial > PHP获取生日对应星座的方法函数

PHP获取生日对应星座的方法函数

WBOY
Release: 2016-06-20 13:05:06
Original
1268 people have browsed it

PHP 获取指定日期对应的星座名称

/**
     * 获取指定日期对应星座
     * 
     * @param integer $month 月份 1-12
     * @param integer $day 日期 1-31
     * @return boolean|string
     */
    public function getConstellation($month, $day)
    {
        $day   = intval($day);
        $month = intval($month);
        if ($month  12 || $day  31) return false;
        $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'=>'摩羯座')
        );
        list($start, $name) = each($signs[$month-1]);
        if ($day <p class="item-note"><br></p>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template