php - PHP遍历数组内对象中的数组
问题描述
我这里有一个很奇怪的 json。我试图遍历每个subscription
对象并获取一些数据
这是json
{
"result":"success",
"data":{
"subscriptions":[
{
"name":"app_generator",
"expirey":1628188363942,
"hwids":3,
"hwids_used":[
"dc253a62ea65cd92c6cb26f15330cf4a8f9e5c3ecf7caae161a3f97de4c84515",
"efede5757f512f9eae1d600302ca5c4e6a3cadb0658310c91c6da2ada68175f4"
]
},
{
"name":"apple",
"expirey":1625596518277,
"hwids":2,
"hwids_used":[
"dc253a62ea65cd92c6cb26f15330cf4a8f9e5c3ecf7caae161a3f97de4c84515",
"dc253a62ea65cd92c6cb26f15330cf4a8f9e5c3ecf7caae161a3f97de4c84515a"
]
}
]
}
}
我试过的代码是:
foreach($json['result']['data']['subscriptions'] as $a)
{
//print_r($a);
$expirey = $a['expirey']
}
我只是收到很多错误。让我知道正确的方法是什么。我的目标是主要获取name
&expirey
数据
解决方案
推荐阅读
- javascript - 反应酶测试
- python - 在python中更改为root用户
- facebook - How to dynamically change content depending on data from Facebook analytics?
- java - Simple Date format returns Wrong date intermittently
- mysql - 查询以在一个 API 中从多个表中获取数据(SpringBOOT + JPA)
- javascript - 使用 webpack 为捆绑代码添加样式
- vue.js - 在 vuejs 中传递多个属性
- ms-access - 插入选择有时有效,有时无效
- ssl - 使用 Spring Boot 应用程序重用 F5 SSL 会话缓存
- jquery - Rails 渲染为 js 切换模式 -> 无法识别的表达式