php根据日期判断星座
<?php
header('Content-type: text/html;charset=UTF-8');
function getConstellation($birthday, $format=null)
{
$pattern = '/^\d{4}-\d{1,2}-\d{1,2}$/';
if (!preg_match($pattern, $birthday, $matchs))
{
return null;
}
$date = explode('-', $birthday);
$year = $date[0];
$month = $date[1];
$day = $date[2];
if ($month <1 || $month>12 || $day < 1 || $day >31)
{
return null;
}
//设定星座数组
$constellations = array(
'摩羯座', '水瓶座', '双鱼座', '白羊座', '...