php json没有引号的解决办法:首先创建一个PHP示例文件;然后通过“function ex_json_decode($s, $mode=false) {...}”方法解决json没有引号的问题即可。

本文操作环境:Windows7系统、PHP7.1版,DELL G3电脑 具体问题: 没有双引号的JSON格式,有什么办法用PHP解开吗。 格式如:{name: "brandId1", type: "String1"} json的标准格式应该是key有双引号,目前第三方数据无引号,请问有什么办法可以解开为数组吗 解决方案: PHP代码如: $s = <<< JSON
{name: "brandId1", type: "String1"}
JSON;
print_r(ex_json_decode($s));
function ex_json_decode($s, $mode=false) {
if(preg_match('/\w:/', $s))
$s = preg_replace('/(\w+):/is', '"$1":', $s);
return json_decode($s, $mode);
}推荐学习:《PHP视频教程》 以上就是php json 没有引号怎么办的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章! |