我正在尝试从 JSON 响应中获取特定值,但无法确定如何定位它。我可以遍历它,但我只想基于键输出单个值,因为响应是动态的,并不总是保证具有相同的输出。
我已将 JSON 响应转换为数组,这里是我目前拥有的示例:
Array (
[0] => Array (
[rel] => advertisements
[href] => https://api.teamsnap.com/v3/advertisements
)
[1] => Array (
[rel] => active_season_team
[href] => https://api.teamsnap.com/v3/teams
)
[2] => Array (
[rel] => assignments
[href] => https://api.teamsnap.com/v3/assignments
)
[3] => Array (
[rel] => availabilities
[href] => https://api.teamsnap.com/v3/availabilities
)
)
我需要能够通过键“rel”来回显“href”值。我努力了:
foreach($links as $key => $value) {
echo $key['advertisements'];
}
但是需要一种方式将 $links 说成 $key->rel = $value->http (这就是我能想到的逻辑)
慕尼黑的夜晚无繁华
Helenr