Created
March 23, 2012 11:25
-
-
Save msng/2169763 to your computer and use it in GitHub Desktop.
全角のみのチェックもうこれでいいんじゃないの
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Requires function is_hankaku() https://gist.github.com/2167287 | |
function is_zenkaku($str, $encoding = null) { | |
if (is_null($encoding)) { | |
$encoding = mb_internal_encoding(); | |
} | |
$len = mb_strlen($str, $encoding); | |
for ($i = 0; $i < $len; $i++) { | |
$char = mb_substr($str, $i, 1, $encoding); | |
if (is_hankaku($char, true, true, $encoding)) { | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment