正则转换问题 \u7684\u9996\u9009\u3002<br><br>---\u66F4\u591A如何将上面的字符串中的\u后面的十六进制转换成十进制数字? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function utf8_replaceEntity($result) { $value = (int)$result[1]; $string = ''; $len = round(pow($value, 1 / 8)); for ($i = $len; $i > 0; $i--) { $part = ($value & (255 >> 2)) | pow(2, 7); if ($i == 1) $part |= 255 << (8 - $len); $string = chr($part).$string; $value >>= 6; } return $string;}function utf8_html_entity_decode($string) { return preg_replace_callback('/&#([0-9]+);/u', 'utf8_replaceEntity', $string);} //本人测试通过。$str='\u7684\u9996\u9009\u3002<br><br>---\u66F4\u591A';preg_match_all('/(\\\u.{4})/i',$str,$matches);foreach($matches[0] as $value) echo hexdec($value).'<br/>';/*303403931836873122902635622810*/ 动用这个utf8_html_entity_decode函数 $data = "\u7684\u9996\u9009\u300F<br><br>---\u66F4\u591A";$returnvalue = '';function test3($matches) { global $returnvalue; $returnvalue .= $matches[1].hexdec($matches[2]).$matches[3];}preg_replace_callback("|(\\\u)(.*)(\\\u)|U", "test3", $data);print_R($returnvalue); A,B两网站跳转与数据合并,如何解决?请求达人给出路!!!! Mysql插入大量数据出错。。。 斗胆请教各位程序高手,如何自动提取他人网页上的数据 求一条isapi_rewrite的url重新规则 新手问题——PHP怎么显示当前时间呢? 同一浏览器四个不同页面,输出不同的sessioni_id 新手提问有关2级联动菜单问题,高手请指点一二 SESSION函数的问题 用PHP发送Cookie,IE与Netscape的差别。 $run->cate->get_cate_db()这是什么鬼呀 您知道这是怎么回事吗:smarty和iframe 帮忙看看啊
$value = (int)$result[1];
$string = ''; $len = round(pow($value, 1 / 8)); for ($i = $len; $i > 0; $i--) {
$part = ($value & (255 >> 2)) | pow(2, 7);
if ($i == 1) $part |= 255 << (8 - $len); $string = chr($part).$string; $value >>= 6;
} return $string;
}function utf8_html_entity_decode($string) {
return preg_replace_callback('/&#([0-9]+);/u', 'utf8_replaceEntity', $string);
}
//本人测试通过。
$str='\u7684\u9996\u9009\u3002<br><br>---\u66F4\u591A';
preg_match_all('/(\\\u.{4})/i',$str,$matches);
foreach($matches[0] as $value)
echo hexdec($value).'<br/>';/*
30340
39318
36873
12290
26356
22810
*/
$returnvalue = '';
function test3($matches) {
global $returnvalue;
$returnvalue .= $matches[1].hexdec($matches[2]).$matches[3];
}preg_replace_callback("|(\\\u)(.*)(\\\u)|U", "test3", $data);
print_R($returnvalue);