汇成软件 Create the world!!!

php正则提取中文

<?php

$str = "用户名123阿斯蒂芬dfsdf阿道夫";
//把结果放在$chinese中
//GBK/GB2312使用:
preg_match_all("/[\x{4e00}-\x{9fa5}]+/u", $str, $chinese);
//UTF-8 使用:
//preg_match_all("/[\x{4e00}-\x{9fa5}]+/u", $str, $chinese);
print_r($chinese);
$count = count($chinese[0]);
for ($x = 0; $x < $count; $x++) {
    echo $chinese[0][$x];
}
?>


 

作者:admin 分类:IT技术 浏览:922 评论:0
留言列表
发表评论
来宾的头像