【问题标题】:How to access the values of this API return如何访问此 API 返回的值
【发布时间】:2019-05-25 14:03:49
【问题描述】:

你能帮帮我吗?我需要知道如何使用 PHP 从 API 调用访问此响应的值。

Array ( [queryIds] => Array ( [0] => lHLLapn7EH ) [timedOutRealtimeData] => [realtimeDataMissing] => [cacheFreshness] => FRESH [prunedResult] => [novaCost] => 0 [novaRequestDuration] = > 19 [wasCached] => 1 [minSampleRate] => 1 [timeComputed] => 1558794556710 [novaRuntime] => 199 [hitChunkGroupByLimit] => [throttleTime] => 0 [data] => Array ([series] => Array ( [0] => 数组 ( [0] => 数组 ( [setId] => [value] => 843 ) ) [1] => 数组 ( [0] => 数组 ( [setId] => [value] => 22 ) ) ) [seriesLabels] => 数组 ( [0] => 数组 ( [0] => 0 [1] => C5241; GB ) [1] => 数组 ( [0] => 0 [1 ] => C9999; GB ) ) [seriesMeta] => 数组 ( [0] => 数组 ( [eventGroupBys] => 数组 ( [0] => C5241 [1] => GB ) [segmentIndex] => 0 [eventIndex ] => 0 [eventGroupBy] => C5241; GB ) [1] => 数组 ( [eventGroupBys] => 数组 ( [0] => C9999 [1] => GB ) [segmentIndex] => 0 [eventIndex] = > 0 [eventGroupBy] => C9999; GB ) ) [seriesCollapsed] => 数组 ( [0] => 数组 ( [0] => 数组 ( [setId] => [value] => 843 ) ) [1] = > 阵列( [0] => 数组 ( [setId] => [value] => 22 ) ) [xValues] => 数组 ( [0] => 2019-05-25 ) ) [partialMergedAndNewUserInformation] => [transformationIds] = > 数组 ( [0] => 2696 ) [后端] => novaV2 )

【问题讨论】:

  • 你需要哪个索引值?
  • 如果没有看到更复杂的数据版本,没有人可以真正给出一个保证在您拥有该数据时有效的答案。您的数据中还有两个Array ( [0] => C9999 [1] => GB ),因此不清楚您想要哪个。
  • 我需要这个 Array ( [0] => C9999 [1] => GB ) , [xValues] => Array ( [0] => 2019-05-25and 我需要 Array ( [ setId] => [value] => 20,问题是这在某些时候很简单,我会像其中许多一样,我需要知道如何访问它们以将它们发送到数据库,我需要一个循环,我可以获得符合数组的代码 C#### 将会增长。

标签: php arrays object


【解决方案1】:

您可以使用它们访问它们

 Array ( [0] => C9999 [1] => GB )  -> $arr['data']['seriesMeta'][0]['eventGroupBys']

Array ( [setId] => [value] => 20) -> $arr['data']['seriesMeta'][0][0]

【讨论】:

  • 但是如果它们像循环一样发生变化,PHP 中有没有办法访问这些值?我刚刚在 API 响应中添加了另一个代码。
猜你喜欢
  • 2023-03-14
  • 2017-11-01
  • 2018-09-16
  • 2020-05-26
  • 2014-05-14
  • 2017-10-25
  • 1970-01-01
  • 2022-01-04
  • 1970-01-01
相关资源
最近更新 更多