<?php
$a = '["u8d27u68af","u505cu8f66u4f4d","u6696u6c14","u6276u68af","u4e0au6c34","u4e0bu6c34","u6392u70df","u6392u6c61","u7ba1u7164","380V","u53efu660eu706b","u5916u6446u533a"]';
$b = json_decode($a);
$array = [];
foreach($b as $k=>$v){
$arr = explode('u',$v);
$arr = array_slice($arr,1,count($arr));
foreach($arr as $k=>$v){
$arr[$k] = "\u".$v;
}
$str = implode('', $arr);
$array[] = $str;
}
//Unicode转汉字
foreach($array as $k=>$v){
$a = decodeUnicode($v);
$array[$k] = $a;
}
var_dump($array);
function decodeUnicode($str)
{
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i',
function ($matches) {
return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");
},
$str);
}
image.png
网友评论