PHP的JSON解析问题
程序员文章站
2024-01-02 18:36:34
...
{"type":"success","code":0,"message":null,"data":{"box_list":[{"boxId":"cfce938f2c7c11e69d5700000a00191c","boxNum":"nantong_test1","boxName":"我的保险柜","boxIp":"","boxMac":"","powerStatus":"0","networkStatus":"0","doorStatus":"2","shakeInfo":"1","deviceStatus":"1","boxStatus":"1","verifyStatus":"","lockPwd":"ABCD07033132333435363F030D","boxVersion":0,"channelId":"nantong_test1","boxControlPwd":"874d05d4bdd9077a7aefa0dc8c8cbd1f","adminUserId":"62f199be303b11e684c000000a00191c","boxPhone":"","defaultSkin":"0","netWorkName":"","agentId":"","createTime":null,"warninhCount":0,"batteryLevel":null,"temp":null},{"boxId":"73b1a2932c7211e69d5700000a00191c","boxNum":"lvlei6","boxName":"我的保险柜","boxIp":"","boxMac":"","powerStatus":"0","networkStatus":"0","doorStatus":"2","shakeInfo":"1","deviceStatus":"1","boxStatus":"1","verifyStatus":"","lockPwd":"ABCD07033132333435363F030D","boxVersion":30,"channelId":"lvlei6","boxControlPwd":"874d05d4bdd9077a7aefa0dc8c8cbd1f","adminUserId":"31f674062c8311e69d5700000a00191c","boxPhone":"","defaultSkin":"0","netWorkName":"","agentId":"","createTime":null,"warninhCount":0,"batteryLevel":null,"temp":null}],"user":{"id":"296d4ecc303d11e684c000000a00191c","userName":"kaka","loginName":"12@qq.com","loginPwd":"874d05d4bdd9077a7aefa0dc8c8cbd1f","userFinger1":"","userFinger2":"","userFinger3":"","type":"0","userPhone":"","userPhoto":"http://hissdata.blob.core.chinacloudapi.cn/userpicdata/296d4ecc303d11e684c000000a00191c_1465717285898.png","channelId":"","userListenDate":1465694992000,"boxNum":"","controlPwd":"","userNum":"","userAddress":"","userMail":"12@qq.com"}}}
要获取box_list中的所有下标下的数据,
我的获取方式$c = $data['data']['box_list'][0]['boxId']; 但是不知为何获取到的是73b1a2932c7211e69d5700000a00191c 也就是box_list中下标为1的boxId。也仅仅只能获取这个 。
求大神!!!!!!!
求大神!!!!!!!
求大神!!!!!!!
回复讨论(解决方案)
没有问题的,你把解析后的数组打印出来核对一下
cfce938f2c7c11e69d5700000a00191c 73b1a2932c7211e69d5700000a00191c