Created
November 26, 2013 09:33
-
-
Save wotupset/7655679 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 | |
header("content-Type: text/html; charset=utf-8"); //語言強制 | |
$str="asd中文ㄍㄍㄍ"; | |
$len = strlen($str); | |
$cc=0; | |
for($i = 0; $i < $len; $i++){ | |
$char = substr($str, $i, 1); //函数返回字符串的一部分 | |
if(ord($char) > 127){//非字母 | |
$arr[$cc][0] = substr($str, $i, 3); //前3字元 函数返回字符串的一部分 | |
$arr[$cc][1] = "3"; | |
$i=$i+2; | |
}else{ | |
$arr[$cc][0] = substr($str, $i, 1); //前1字元 函数返回字符串的一部分 | |
$arr[$cc][1] = "1"; | |
} | |
$cc=$cc+1; | |
} | |
echo "<pre>".print_r($arr)."</pre>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment