PHP cuts a string containing Chinese and English ASCII codes into a single word array_PHP tutorial

WBOY
Release: 2016-07-13 17:46:36
Original
1330 people have browsed it

//Cut the string containing Chinese and English ASCII codes into a single word array

//Satan@Author 2011-10-26

private function chinesesplit($str){

//$str="

$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;

}

Excerpted from Rotting in a Coffin

http://www.bkjia.com/PHPjc/478565.html

true http: //www.bkjia.com/PHPjc/478565.html TechArticle //Cut the string containing Chinese and English ASCII codes into a single word array//Satan@Author 2011-10-26 private function chinesesplit($str){ //$str=x little girls went to KFC to eat chicken, the flying knife has been taken, nobo...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!