How could you access the name
one located in league?
I was able to access lastName
with this:
$url = "https://www.easports.com/fifa/ultimate-team/api/fut/item";
$response = Http::get($url);
$data = $response->json(['items']);
foreach ($data as $obj) {
$name = "nombre de jugador: ". $obj['firstName'] . '<br>';
print ($name);
}
"items": [{
"commonName": "Cristiano Ronaldo",
"firstName": "C. Ronaldo",
"lastName": "dos Santos Aveiro",
"league": {
"imageUrls": {},
"abbrName": "ITA 1",
"id": 31,
"imgUrl": null,
"name": "Serie A TIM"
},
}],
I am getting the data from https://www.easports.com/fifa/ultimate-team/api/fut/item
In the same way that to access firstName you use
To get the name that is located in league you have to do
That would be to get only him
name
, but if you wanted to get all of them, you could do it by hand 1 by 1 or you could do another foreach just like you did withbut this time with the league data. Something like