Share a function method that uses PHP to get the corresponding Ganzhi annals, Zodiac and constellation information based on a date or time stamp, the specific function code, and the following methods are used:
/** Judge Ganzhi, Zodiac and constellation */function Birthext ($birth) {if (Strstr ($birth, '-') ===false&&strlen ($birth)!==8) {$bir
Th=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 ', ' 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]) {bre Ak }} $result [' XZ ']= $xzdict [$i]. '
Seat '; $gzdict =array (' A ', ' B ', ' C ', ' ding ', ' e ',' Self ', ' Geng ', ' xin ', ' ren ', '), Array (' son ', ' ugly ', ' Yin ', ' Mao ', ' Chen ', ' si ', ' afternoon ', ' not ', ' shen ', ' unitary ', ' Xu ', ' Hai '));
$i = $y -1900+36;//http://www.alixixi.com/$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> ';//http://www. alixixi.com/php-function/868.html
$arr =birthext (' 1373287361 ');//time Stamp
Print_r ($arr);
$arr =birthext (' 2013-07-08 ');
Print_r ($arr);
$arr =birthext (' 20130708 ');
Print_r ($arr);
Print the results as follows:
Array
(
[XZ] => cancer
[GZ] =>
[SX] => snake
)
Array
(
[XZ] => cancer
[GZ] =>
[SX] => snake
)
Array
(
[XZ] => cancer
[GZ] =>
[SX] => snake
)
In addition, if you need to obtain more detailed information can refer to this site article:
PHP Solar to Lunar (lunar), lunar calendar method