Php computing 12 constellation function code

Source: Internet
Author: User
Calculate the Constellation function stringget_zodiac_sign. if you need it, refer to the following core code:
The code is as follows:
/*
* Calculate the Constellation function string get_zodiac_sign (string month, string day)
* Input: month, date
* Output: Constellation name or error message
*/

Function get_zodiac_sign ($ month, $ day)
{
// Check the parameter validity
If ($ month <1 | $ month> 12 | $ day <1 | $ day> 31)
Return (false );
// Constellation name and start date
$ Signs = array (
Array ("20" => "babyworks "),
Array ("19" => "Pisces "),
Array ("21" => "Aries "),
Array ("20" => "Taurus "),
Array ("21" => "Gemini "),
Array ("22" => "cancer "),
Array ("23" => "Leo "),
Array ("23" => "Virgo "),
Array ("23" => "Libra "),
Array ("24" => "Scorpio "),
Array ("22" => "Sagittarius "),
Array ("22" => "Capricorn ")
);
List ($ sign_start, $ sign_name) = each ($ signs [(int) $ month-1]);
If ($ day <$ sign_start)
List ($ sign_start, $ sign_name) = each ($ signs [($ month-2 <0 )? $ Month = 11: $ month-= 2]);
Return $ sign_name;
} // Function End
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.