1
I am trying to access a multidimensional Json via Windows and I am not getting the expected result, I need to access phases->games->data->2017-05-13 I will post the code below to find a solution:
My array:
Controller.php
public function index(){
// JSON DOS ARQUIVOS
$arquivo_json = file_get_contents('http://jsuol.com.br/c/monaco/utils/gestor/commons.js?file=commons.uol.com.br/sistemas/esporte/modalidades/futebol/campeonatos/dados/2017/30/dados.json');
$dadosJson = json_decode($arquivo_json, true);
return view('ler', compact('dadosJson'));
}
view php.
@foreach($dadosJson['fases'] as $equipes)
@foreach($equipes['jogos'] as $jogos)
{{ $jogos['nome'] }}
@endforeach
@endforeach
Could someone give me a hand?
Thank you!
You seem to be right. Maybe you have some
data
ofjogos
that does not exist. Make a condition before checking if the key exists to continue.if(array_key_exists('data', $jogos'))
.– Diego Souza
Good morning @Diego-Souza, I did as follows foreach($dadosJson['phases'] the $teams) if(array_key_exists('data', $games')) foreach($teams['games'] the $games) {{ $games['name'] }} endforeach endforeach !
– Cristiano Facirolli