文档归类:编程开发
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(
'摩羯座', '水瓶座', '双鱼座', '白羊座', '金牛座', '双子座',
'巨蟹座','狮子座', '处女座', '天秤座', '天蝎座', '射手座',);
//设定星座结束日期的数组,用于判断
$enddays = array(19, 18, 20, 20, 20, 21, 22, 22, 22, 22, 21, 21,);
//如果参数format被设置,则返回值采用format提供的数组,否则使用默认的数组
if ($fo...
太给力了,去围观»
function msubstr($str, $start=0, $length, $charset="utf-8", $suffix=true) {
if(function_exists("mb_substr")){
$slice = mb_substr($str, $start, $length, $charset);
$strlen = mb_strlen($str,$charset);
}elseif(function_exists('iconv_substr')) {
$slice = iconv_substr($str,$start,$length,$charset);
$strlen = iconv_strlen($str,$charset);
if(false === $slice) {
$slice = '';
}
}else{
$re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
$re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";
$re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";
$re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/...
博主太强大了,膜拜去»
php判断是不是移动客户端,php判断客户端系统类型
[php]
<?php
function checkmobile() {
global $_G;
$mobile = array();
static $mobilebrowser_list =array('iphone', 'android', 'phone', 'mobile', 'wap', 'netfront', 'java', 'opera mobi', 'opera mini',
'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia', 'samsung',
'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser',
'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith', 'palmsource',
'alcatel', 'amoi', 'ktouch', 'nexi...
我只是想看完而已»