+
80
-

php怎么正则替换字符串中的中文汉字?

php
php怎么正则替换字符串中的中文汉字?

网友回复

+
1
-
<?php
header("Content-type:text/html;charset=utf-8");
$str = "http://www.bfw.wiki/架构专题/111/如何成为架构高手.html";

echo preg_replace("/([\x{4e00}-\x{9fa5}]+)/ue",'urlencode("$1")',$str);

// preg_match_all("/([\x{4e00}-\x{9fa5}]+)/u",$str,$match);

// var_dump($match);

我知道答案,我要回答