Ich versuche, eine Ausgabe von einer API zu codieren.Wie gibt man ein spezifisches Array in PHP aus?
Also nahm ich dies zuerst:
$api_response = json_decode(file_get_contents("--LINK TO API--"));
wenn ich den $ api_response var_dump, einen Code wie
object(stdClass)#1 (3) {
["status"]=>
string(2) "ok"
["count"]=>
int(1)
["data"]=>
array(1) {
[0]=>
object(stdClass)#2 (4) {
["clan_id"]=>
int(1000001876)
["nickname"]=>
string(10) "JakenVeina"
["id"]=>
int(1001147659)
["account_id"]=>
int(1001147659)
}
}
}
Also, wenn ich nur die account_id zum Beispiel ausgegeben werden soll, habe ich versucht, mehr Wege:
$account_id = $api_response["data"]["account_id];
echo $account_id;
und
echo $api_response->account_id;
Nichts funktionierte für mich. Hat jemand eine Idee?
Ich weiß nicht, ob es hier oder in Ihrem Code einen Tippfehler gibt, aber Sie vermissen einen "am Ende von $ account_id = $ api_response [" data "] [" account_id]; ' – Andreas