Share a function method that uses PHP to get the corresponding Ganzhi annals, Zodiac and constellation information based on a date or timestamp, the specific function code, and the following methods:
/** Judge Ganzhi, Zodiac and constellation */function Birthext ($birth) {if (Strstr ($birth, '-') ===false&&strlen ($birth)!==8) {$birth =d
Ate ("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 ', ' Gemini ', ' Giant crab ', ' lion ', ' virgin ', ' Libra ', ' Scorpio ', ' Archer ');
$zone =array (1222,122,222,321,421,522,622,722,822,922,1022,1122,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 ', ' C ', ' ding ', ' e ', ' self ', ' Geng ', ' xin ', ' Ren ', ' gui '), Array (' son ', ' ugly ', ' I ', ' Mao ', ' Chen ', ' si ', ' afternoon ', ' not ', ' shen ', ', ', '
, ' Hai ')); $i = $y-1900+36;
$result [' GZ ']= $gzdict [0][($i%10)]. $gzdict [1][($i%12)];
$sxdict =array (' rat ', ' ox ', ' tiger ', ' Rabbit ', ' dragon ', ' snake ', ' horse ', ' sheep ', ' monkey ', ' chicken ', ' dog ', ' pig ');
$result [' SX ']= $sxdict [(($y-4)%12]];
return $result; }
Use the following example:
<?php
Header ("Content-type:text/html;charset=utf-8");
Echo ' <pre> ';
$arr =birthext (' 1373287361 '); Time Stamp
Print_r ($arr);
$arr =birthext (' 2013-07-08 ');
Print_r ($arr);
$arr =birthext (' 20130708 ');
Print the results as follows:
The above is about PHP based on the date or time stamps to obtain constellation information and zodiac information, such as the function method, I hope to help you learn.