为什么字符替换会出现乱马? str_replace("数组","<font color='red'>数组</font>",$str);这样还会有乱吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 单字节和双字节公用的时候,使用str_replace时候会出现乱码现象。 可以加载php_mbstring.dll模块,使用宽字节函数。 到那里可以找到这个模块php_mbstring.dll,如何加载?谢谢! function chn_str_replace($needle,$string,$haystack) { $l = strlen($haystack); $l2 = strlen($needle); $l3 = strlen($string); $news = ""; $skip = 0; $a = 0; while ($a < $l) { $ch = substr($haystack,$a,1); $ch2 = substr($haystack,$a+1,1); if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) { if (substr($haystack,$a,$l2) == $needle) { $news .= $string; $a += $l2; } else { $news .= $ch.$ch2; $a += 2; } } else { if (substr($haystack,$a,$l2) == $needle) { $news .= $string; $a += $l2; } else { $news .= $ch; $a++; } } // END IF } // END WHILE return $news;} 正则表达式抓取网页部分内容 大家来看看我的NGINX的日志 OB_start 缓存输出后为乱码 用于php获取XML值 求MYSQL优化方案 备份工具ebak的问题,在线等 ???哪位大侠来帮帮我啊!!! php+mysql分页的困惑!每个分页都运行2次检索数据库的脚本? mysql4.1.10与php的连接语句? Zend Optimizer 在windows 2000 高级服务器版下安装的问题? mysql数据插入错误 高手请进 请进来帮一下忙,同时有好东西共享:)
$l = strlen($haystack);
$l2 = strlen($needle);
$l3 = strlen($string);
$news = "";
$skip = 0;
$a = 0;
while ($a < $l) {
$ch = substr($haystack,$a,1);
$ch2 = substr($haystack,$a+1,1);
if (ord($ch) >= HexDec("0x81") && ord($ch2) >= HexDec("0x40")) {
if (substr($haystack,$a,$l2) == $needle) {
$news .= $string;
$a += $l2;
} else {
$news .= $ch.$ch2;
$a += 2;
}
} else {
if (substr($haystack,$a,$l2) == $needle) {
$news .= $string;
$a += $l2;
} else {
$news .= $ch;
$a++;
}
} // END IF
} // END WHILE
return $news;
}