The following is a function that uses PHP to determine which constellation a date belongs to. For more information, see
The code is as follows:
Function yige_constellation ($ month, $ day ){
// Check the parameter validity
If ($ month <1 | $ month> 12 | $ day <1 | $ day> 31) return false;
// Constellation name and start date
$ Constellations = 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 ($ constellation_start, $ constellation_name) = each ($ constellations [(int) $ month-1]);
If ($ day <$ constellation_start) list ($ constellation_start, $ constellation_name) = each ($ constellations [($ month-2 <0 )? $ Month = 11: $ month-= 2]);
Return $ constellation_name;
}
Call example:
The code is as follows:
Echo yige_constellation (4, 20 );