php json_decode解析json文件问题。
2017-03-25 17:33
555 查看
怎样能将下面json的格式的value一个一个的用echo显示出来?谢谢
输出结果:
array(3) {
["traffic.statistics"]=>
array(2) {
["ethernet.bytes"]=>
int(1901)
["low.protos"]=>
int(2)
}
["detected.protos"]=>
array(2) {
[0]=>
array(4) {
["name"]=>
string(6) "DHCPV6"
["packets"]=>
int(1)
["bytes"]=>
int(149)
["flows"]=>
int(1)
}
[1]=>
array(4) {
["name"]=>
string(5) "LLMNR"
["packets"]=>
int(4)
["bytes"]=>
int(296)
["flows"]=>
int(2)
}
}
["known.flows"]=>
array(0) {
}
}
NULL
<?php $json_file = "list.json"; $handle = fopen($json_file , "r"); $contents = fread($handle,filesize($json_file)); fclose($handle); // $js = json_decode($contents); // print_r $js; foreach (range(4, 3, -1) as $depth) { var_dump(json_decode($contents, true, $depth)); } ?>
输出结果:
array(3) {
["traffic.statistics"]=>
array(2) {
["ethernet.bytes"]=>
int(1901)
["low.protos"]=>
int(2)
}
["detected.protos"]=>
array(2) {
[0]=>
array(4) {
["name"]=>
string(6) "DHCPV6"
["packets"]=>
int(1)
["bytes"]=>
int(149)
["flows"]=>
int(1)
}
[1]=>
array(4) {
["name"]=>
string(5) "LLMNR"
["packets"]=>
int(4)
["bytes"]=>
int(296)
["flows"]=>
int(2)
}
}
["known.flows"]=>
array(0) {
}
}
NULL
相关文章推荐
- PHP json_decode 无法解析特殊问号字符
- PHP中使用了mcrypt_decrypt函数处理Json串后导致Json_decode返回null问题
- IOS问题汇总:2015-1-8 SBJson解析时报错—json文件字符非法
- ueditor上传图片时目录创建失败的问题解决方法,不用那么麻烦,其实修改php/config.json这个配置文件里面的路径就行!!
- PHP json_decode 函数解析 json 结果为 NULL 的解决方法
- ajaxfileupload_v.js 解决js版本不兼容,多文件上传不解析json的问题
- php解决aes,base64后的json字符串json_decode为null的问题
- php解析json文件时为何不出任何效果?
- nginx解析php文件及问题
- PHP json_decode 函数解析 json 结果为 NULL 的解决方法
- php解析post文件用php://input获取不到的问题
- php json_decode 无法解析,返回值null
- PHP以及JSON中的转义问题解析
- 关于centOs下Apache不解析php文件问题的解决方法
- C#字符串数组排序 C#排序算法大全 C#字符串比较方法 一个.NET通用JSON解析/构建类的实现(c#) C#处理Json文件 asp.net使用Jquery+iframe传值问题
- 解决PHP Json_decode 解析失败
- PHP文件数据传输用jQuery-ajax进行浏览器->服务器->数据文件->服务器->浏览器的数据传输($_POST,$_GET,json_encode(数组数据回应),json数据解析)
- PHP中file_get_contents函数获取带BOM的utf-8,然后json_decode() 返回null的问题
- PHP:json_decode解析JSON数据
- 解决PHP下json_decode返回NULL的问题。