正则转换问题 \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); ruby到底是什么。。。 有没有需要友情链接的? PHP一个传递的问题··· Can't create TCP/IP socket (5) 谁能解决了这个问题为大家造福啊??? 配置文件 一直不明白是怎么事 关于数组排序 一个SQL查询问题 问个Ox和eval的问题 初学PHP,Apache服务器,关于首页的直接显示问题 [求职]准备换工作!贴简历一份 您知道这是怎么回事吗: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);