Php calculates the function code of the 12 constellation. Core code: Copy the code as follows :? Php ** calculate the Constellation function stringget_zodiac_sign (stringmonth, stringday) * input: month, date * output: Constellation name or wrong 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
?>
The pipeline code is as follows :? Php/** calculate the Constellation function string get_zodiac_sign (string month, string day) * input: month, date * output: Constellation name or error...