PHP to determine the function of a constellation based on a specific date
Now it's kind of popular to discuss constellations, the following authors share a function that uses PHP to determine which constellation a date belongs to. The specific function code is as follows:
function constellation ($month, $day) {//Check parameter validity http://www.phpernote.com/if ($month <1| | $month >12| | $day <1| | $day >31) return false;//constellation name and start date $constellations=array ("+" and "Aquarius"), Array ("+" + "Pisces"), Array ("21 "=" and "Aries"), Array ("+" and "Taurus"), Array ("+" and "Gemini"), Array ("+" and "cancer"), Array ("Max" = "Leo"), Array ("23 "=" and "Virgo"), Array ("+" = "Libra"), Array ("+" and "Scorpio"), Array ("+" and "Sagittarius"), Array ("+" = "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;}
Example of a function call:
Echo Constellation (4, 20);
Articles you may be interested in
- Php method for retrieving Ganzhi, Zodiac and constellation information based on date or time stamp
- PHP Extract the birthday date from the ID number and the function to verify whether it is a minor
- PHP calculates the function of two dates apart, how many months, how many days
- PHP calculates the number of days (day) of a two-date function
- PHP Digital Judgment function
- How PHP determines if a GIF is a dynamic picture (animated)
- PHP gets a method for each month in a certain period of time, returning an array of these months
- PHP calculates a function that is currently the first week of the year or January
http://www.bkjia.com/PHPjc/919715.html www.bkjia.com true http://www.bkjia.com/PHPjc/919715.html techarticle PHP's function of judging constellations based on specific dates now seems to be quite popular for discussion constellations, the following authors share a function that uses PHP to determine which constellation the specified date belongs to. Specific function generation ...