把每个中文用空格隔开问题! 本帖最后由 kiqigai 于 2011-07-22 13:38:14 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 还要写个类啊?替换utf-8中文就行了吧$str = '富士拍立得mini25相机';echo preg_replace('#[\x{4e00}-\x{9fa5}]#u',' $0 ',$str); //a.class.php class Replace{ private $str; function __construct($str){ $this->str=$str; } function replace(){ echo preg_replace("/[\x{4e00}-\x{9fa5}]/u",' $0 ' ,$this->str); } }//test.phpinclude_once("a.class.php");$r=new Replace('富士拍立得mini25相机');$r->replace();富 士 拍 立 得 mini25 相 机 echo preg_replace('/[\x80-\xff]{3}/', ' $0 ', '富士拍立得mini25相机'); 富 士 拍 立 得 mini25 相 机 一个年度考勤统计系统的设计 刚建立了鳄鱼网,如何运营呢 哪里有PHP3下载?求助 基础问题 一个进程如何去和另个进程通信 如何把Apache设为默认的服务器?跪谢 关于PHP的多线程问题 成功显示php图片验证码,不知道接下来做什么? 急,php如何接受 html的索引值 怎么把tiff格式图像转化为jpeg 或gif格式图像,谢谢. PHP插入数据问题 php中调用mysql出错 在线求助
替换utf-8中文就行了吧
$str = '富士拍立得mini25相机';
echo preg_replace('#[\x{4e00}-\x{9fa5}]#u',' $0 ',$str);
//a.class.php
class Replace{
private $str;
function __construct($str){
$this->str=$str;
}
function replace(){
echo preg_replace("/[\x{4e00}-\x{9fa5}]/u",' $0 ' ,$this->str);
}
}
//test.php
include_once("a.class.php");
$r=new Replace('富士拍立得mini25相机');
$r->replace();富 士 拍 立 得 mini25 相 机