解决php中json_decode的异常JSON_ERROR_CTRL_CHAR

解决php中json_decode的异常JSON_ERROR_CTRL_CHAR

该字符中含了ASCII码ETB控制符,即\x17导致json解析失败 (截图中显示ETB是因为用了Sublime text2)

解决方法如下:去掉0-31的控制符再进行decode

$result = "json格式字符串如图";
$result = preg_replace('/[\x00-\x1F]/','', $result);
$result = json_decode($result);
上一篇:VUE 采坑之旅-- Mint-ui 按需引入报出Module build failed: Error: Couldn't find preset "es2015" relative to directory "C:\\phpStudy\\PHPTutorial\\WWW\\text\\vuep\\vue-demo"


下一篇:适配ipone5