This article mainly introduces how php obtains information about the constellation and zodiac based on the date or time stamp, if you need a function, you can refer to the following section to share a function that uses php to obtain the relevant information about the calendar year, Zodiac, and Constellation based on the date or time stamp. the specific function code and usage method are as follows:
/** Determine Ganzhi, Zodiac, and Constellation */function birthext ($ birth) {if (strstr ($ birth ,'-') ===false & strlen ($ birth )! = 8) {$ birth = date ("Y-m-d", $ birth);} if (strlen ($ birth) = 8) {if (eregi ('([0-9] {4}) ([0-9] {2}) ([0-9] {2}) $ ', $ birth, $ bir) $ birth = "{$ bir [1]}-{$ bir [2]}-{$ bir [3]}";} if (strlen ($ birth) <8) {return false;} $ tmpstr = explode ('-', $ birth); if (count ($ tmpstr )! = 3) {return false;} $ y = (int) $ tmpstr [0]; $ m = (int) $ tmpstr [1]; $ d = (int) $ tmpstr [2]; $ result = array (); $ xzdict = array ('capricorn ', 'Aquarius', 'pisces ', 'aries', 'Taurus ', 'gemine', 'Cancer ', 'Lions', 'virgins ', 'Libra', 'Scorpio ', 'Sagittarius'); $ zone = array (1222,122,222,321,421,522,622,722,822,922,102, 1222 ); if (100 * $ m + $ d) >=$ zone [0] | (100 * $ m + $ d) <$ zone [1]) {$ I = 0;} else {for ($ I = 1; $ I <12; $ I ++) {if (100 * $ m + $ d)> = $ zone [$ I] & (100 * $ m + $ d) <$ zone [$ I + 1]) {break ;}}} $ result ['xz '] = $ xzdict [$ I]. 'seat '; $ gzdict = array ('A',' B ', 'Bing', 'ding', 'pente', 'Ji', 'geng ', 'Sin', 'hire', 'dece'), array ('sub', 'Ugly ', 'yin', 'Mao ', 'Chen', 'Si ', 'Wu ', 'Wei', 'Shen ', 'you', 'haid'); $ I = $ y-1900 + 36; $ result ['gz '] = $ gzdict [0] [($ I % 10)]. $ gzdict [1] [($ I % 12)]; $ sxdict = array ('Rat ', 'ox', 'Tiger ', 'rabbit', 'Dragon ', 'Snake ', 'ma', 'goat', 'Monkey ', 'Chicken', 'dog ', 'Pig '); $ result ['sx '] = $ sxdict [($ Y-4) % 12)]; return $ result ;}
Example:
<? Php header ("Content-Type: text/html; charset = utf-8"); echo''; $ Arr = birthext ('20140901'); // timestamp print_r ($ arr); $ arr = birthext ('2017-07-08'); print_r ($ arr ); $ arr = birthext ('20140901'); print_r ($ arr );
The output is as follows:
The above is aboutPhp obtains information about the constellation and zodiac based on the date or time stamp.Function method, hope to help you learn.