//含有中英文ASCII碼字符串切割為單字數組
//Satan@Author 2011-10-26
private function chinesesplit($str){
//$str="x個小姑娘去kfc吃chicken,飛刀已出手,nobody看到什麼時候出手的,Mr'Li手中仍握著那個木雕,但刀已不在noanymore";
$ascLen=strlen($str);
for($i;$i<$ascLen;$i++){
$c=ord(substr($str,0,1));
if(ord(substr($str,0,1)) >252){$p = 5;}elseif($c > 248){$p = 4;}elseif($c > 240){$p = 3;}elseif($c > 224){$p = 2;}elseif($c > 192){$p = 1;}else{$p = 0;}
$truekey=substr($str,0,$p+1);
if($truekey===false){break;}
$splikey[]=$truekey;
$str=substr($str,$p+1);
}
return $splikey;
}
摘自 爛在棺材裡