Core code:
Copy code The code is as follows:
/*
* Calculate the zodiac sign Function string get_zodiac_sign(string month, string day)
* Input: month, day
* Output: constellation name or error message
*/
function get_zodiac_sign($month, $day )
{
// Check parameter validity
if ($month < 1 || $month > 12 || $day < 1 || $day > 31)
return (false);
// Constellation name and start date
$signs = array(
array( "20" => "Aquarius"),
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;
}//End of function
?>
http://www.bkjia.com/PHPjc/325719.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325719.htmlTechArticleCore code: Copy the code as follows: ?php /* * Function string to calculate the constellation get_zodiac_sign(string month, string day) * Input: month, date * Output: Constellation name or wrong...