WechatIMG129.jpeg
- 轉(zhuǎn)碼
function userTextEncode($str){
if(!is_string($str)) return $str;
if(!$str || $str=='undefined') return '';
$text = json_encode($str);
$text = preg_replace_callback("/(\\\u[ed][0-9a-f]{3})/i",function($str){
return addslashes($str[0]);
},$text);
return json_decode($text);
}
- 解碼
function userTextDecode($str){
$text = json_encode($str);
$text = preg_replace_callback('/\\\\\\\\/i',function($str){
return '\\';
},$text);
return json_decode($text);
}