为什么字符替换会出现乱马? 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;} 关于PHP把字符串转成图片的问题 这两句SQL怎样拼成一句 请问:为什么红色部分语句会显示为NULL呢? mysql_fetch_array()问题 php正则匹配嵌套<div>标签的问题 [大家注意啦!!!]中智上海招聘以下人员 关于使用 session_start 出现的 headers already sent错误(请求高手帮助) 刚学PHP。请问PHP中 $ 是什么意思?为什么定义变量、数组等都要加上这个玩意? PHP與session的問題急急急.... 求复杂正则(高手请进!)急!! 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;
}