您好,登錄后才能下訂單哦!
本篇內容主要講解“php怎么根據(jù)日期顯示所在星座”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“php怎么根據(jù)日期顯示所在星座”吧!
本文實例講述了php根據(jù)日期顯示所在星座的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
<?php function zodiac($DOB){ $DOB = date("m-d", strtotime($DOB)); list($month,$day) = explode("-",$DOB); if(($month == 3 || $month == 4) && ($day > 22 || $day < 21)){ $zodiac = "Aries"; } elseif(($month == 4 || $month == 5) && ($day > 22 || $day < 22)){ $zodiac = "Taurus"; } elseif(($month == 5 || $month == 6) && ($day > 23 || $day < 22)){ $zodiac = "Gemini"; } elseif(($month == 6 || $month == 7) && ($day > 23 || $day < 23)){ $zodiac = "Cancer"; } elseif(($month == 7 || $month == 8) && ($day > 24 || $day < 22)){ $zodiac = "Leo"; } elseif(($month == 8 || $month == 9) && ($day > 23 || $day < 24)){ $zodiac = "Virgo"; } elseif(($month == 9 || $month == 10) && ($day > 25 || $day < 24)){ $zodiac = "Libra"; } elseif(($month == 10 || $month == 11) && ($day > 25 || $day < 23)){ $zodiac = "Scorpio"; } elseif(($month == 11 || $month == 12) && ($day > 24 || $day < 23)){ $zodiac = "Sagittarius"; } elseif(($month == 12 || $month == 1) && ($day > 24 || $day < 21)){ $zodiac = "Cpricorn"; } elseif(($month == 1 || $month == 2) && ($day > 22 || $day < 20)){ $zodiac = "Aquarius"; } elseif(($month == 2 || $month == 3) && ($day > 21 || $day < 21)){ $zodiac = "Pisces"; } return $zodiac; } echo zodiac('1986-07-22'); //Valid strtotime date ?>
到此,相信大家對“php怎么根據(jù)日期顯示所在星座”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續(xù)學習!
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。