2
I need to pull the leaderboard of football: position, coat of arms, team name, points, games, wins, goal balance. I’m pulling from an API, see the PHP code I tried:
<?php
header("Content-Type: application/json");
$jsonData = file_get_contents("http://json.gazetaesportiva.com/brasileiro-serie-a-2019.json");
$arrData = json_decode($jsonData); // Transforma o seu JSON
// print_r($arrData)
echo "<pre>";
print_r($arrData);
echo "</pre>";
print_r ($arrData->grupos);
foreach($obj2 as $key => $value){
$tier = $value[0]->nome;
$division = $value[0]->entries[0]->division;
}
?>
This is part of the result:
[17] => stdClass Object
(
[equipe] => stdClass Object
(
[id] => 13
[nome] => Chapecoense
[abreviacao] => CHA
[pais] => Brasil
[imagem] => stdClass Object
(
[url] => https://img-apifutebol.gazetaesportiva.com/uploads/equipe/imagem/chapecoense.png
[thumb] => stdClass Object
(
[url] => https://img-apifutebol.gazetaesportiva.com/uploads/equipe/imagem/thumb_chapecoense.png
)
)
[imagem_foi_obtida_via_url] => 0
[slug] => chapecoense
[pagina_site] => chapecoense
)
[pontos] => 9
[jogos] => 12
[vitorias] => 2
[empates] => 3
[derrotas] => 7
[gols_pro] => 11
[gols_contra] => 20
[saldo_gols] => -9
[aproveitamento] => 25
[penalidades] => 0
)
[18] => stdClass Object
(
[equipe] => stdClass Object
(
[id] => 1510
[nome] => CSA
[abreviacao] => CSA
[pais] => Brasil
[imagem] => stdClass Object
(
[url] => https://img-apifutebol.gazetaesportiva.com/uploads/equipe/imagem/csa.png
[thumb] => stdClass Object
(
[url] => https://img-apifutebol.gazetaesportiva.com/uploads/equipe/imagem/thumb_csa.png
)
)
[imagem_foi_obtida_via_url] => 0
[slug] => csa
[pagina_site] => csa
)
[pontos] => 7
[jogos] => 12
[vitorias] => 1
[empates] => 4
[derrotas] => 7
[gols_pro] => 3
[gols_contra] => 20
[saldo_gols] => -17
[aproveitamento] => 19
[penalidades] => 0
)
[19] => stdClass Object
(
[equipe] => stdClass Object
(
[id] => 7
[nome] => Avaí
[abreviacao] => AVA
[pais] => Brasil
[imagem] => stdClass Object
(
[url] => https://img-apifutebol.gazetaesportiva.com/uploads/equipe/imagem/avai.png
[thumb] => stdClass Object
(
[url] => https://img-apifutebol.gazetaesportiva.com/uploads/equipe/imagem/thumb_avai.png
)
)
[imagem_foi_obtida_via_url] => 0
[slug] => avai
[pagina_site] => avai
)
[pontos] => 5
[jogos] => 12
[vitorias] => 0
[empates] => 5
[derrotas] => 7
[gols_pro] => 5
[gols_contra] => 16
[saldo_gols] => -11
[aproveitamento] => 13
[penalidades] => 0
)
)
)
)
<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined variable: obj2 in C:\wamp\www\esporte\index.php on line <i>13</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0320</td><td bgcolor='#eeeeec' align='right'>387000</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\esporte\index.php' bgcolor='#eeeeec'>...\index.php<b>:</b>0</td></tr>
</table></font>
<br />
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: Invalid argument supplied for foreach() in C:\wamp\www\esporte\index.php on line <i>13</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0320</td><td bgcolor='#eeeeec' align='right'>387000</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\esporte\index.php' bgcolor='#eeeeec'>...\index.php<b>:</b>0</td></tr>
</table></font>
I’m having trouble leaving only the data, and changing their position and formatting. Thanks in advance.
what are you specifically trying to generate??? would only be the leaderboard??
– Oliveira
@Oliveira Yes, only the classification table.
– jose113