文字列系
参考URL
文字数をカウントする(mbstringが使えなくて・・・)
function strlen_check($str, $max) {
$zenkaku_code_s = hexdec(80); // 全角コード開始
$hankana_code_s = hexdec(A0); // 半角カナコード開始
$hankana_code_e = hexdec(DF); // 半角カナコード終了
$str_cnt = 0; // 文字数
for ($str_p=0; $str_p<strlen($str); $str_p++) {
$tmp1 = substr($str,$str_p,1);
$tmp2 = bin2hex($tmp1);
$tmp3 = hexdec($tmp2);
if ( $tmp3 ) $str_cnt++;
// 全角2バイトの場合は、チェックポイント++
if ( $zenkaku_code_s <= $tmp3 && !( $hankana_code_s <= $tmp3 && $tmp3 <= $hankana_code_e) ) $str_p++;
}
if ( $str_cnt > $max ) return false;
else return true;
}
季節と月をチェックする
$_SEASON_MONTH = array(
'0' => array(3,4,5) // 春(3,4,5月)
,'1' => array(6,7,8) // 夏(6,7,8月)
,'2' => array(9,10,11) // 秋(9,10,11月)
,'3' => array(1,2,12) // 冬(1,2,12月)
);
function checkSeason($season=0,$month=0) {
global $_SEASON_MONTH;
if (!array_search($month, $_SEASON_MONTH[$season])) return false;
else return true;
}
最終更新:2008年09月07日 19:57