最後更新日期:2021年08月01日
將輸入生日的unixtime,並回傳所屬的生肖
在很多會員系統當中,有可能會用到
<?PHP
# 輸入unix time換算生肖
function unixtime_to_zodiac($unixtime)
{
$year = intval(date('Y',$unixtime));
switch (($year - 4) % 12)
{
case 0:
$zodiac = 'mouse';
break;
case 1:
$zodiac = 'cow';
break;
case 2:
$zodiac = 'tiger';
break;
case 3:
$zodiac = 'rabbit';
break;
case 4:
$zodiac = 'dragon';
break;
case 5:
$zodiac = 'snake';
break;
case 6:
$zodiac = 'horse';
break;
case 7:
$zodiac = 'sheep';
break;
case 8:
$zodiac = 'monkey';
break;
case 9:
$zodiac = 'chicken';
break;
case 10:
$zodiac = 'dog';
break;
case 11:
$zodiac = 'pig';
break;
}
return $zodiac;
}
可以放入library當中,應該有機會可以用到
如果您喜歡我的文章或是我的文章對您有幫助,歡迎幫我點讚或分享,謝謝您的觀看