0
to performing a file_get_contents php on a site, ai shows all teams of this site, in the for each loop it shows me all the time ( that are between the file tags ), but wanted to turn all these teams into Json Find ( turn into API ).
Because of file_get_contents php I can not transform this data into array to be displayed in Json Encode, I tried a lot and did not have a positive result, I will leave my code, if someone gets this.
only thing I got was a response ( a team ), in case I wanted all teams.
<?php
echo "[";
// URL DO SITE
$url = ' url do site';
// PEGANDO TODO CONTEUDO
$dadosSite = file_get_contents($url);
$var1 = explode('<h4><b>',$dadosSite);
//possivel filtro
foreach( $var1 as $idArray => $array){
if($i)
{
$horajogo = explode('</b></h4>',$array);
//=======> time um
// filtrar o que voce quer
$timeum = explode('width="25" height="25">',$array);
// filtrar ate onde voce quer
$timeum = explode('</div>',$timeum[1]);
$cliente1 = array(
'codigo' => $timeum[0],
);
}
$i++;
}
echo json_encode($cliente1, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
?>
I wanted to do something like, but it shows up ALL the teams.
[{
"camp": "Campeonato Brasileiro",
"hrs": "22:00",
"time": "Arsenal",
"img": "https://futebolnatv.com.br/static/times/33a929f9e1e26c8a52e0b2c1bee44d6e.png",
"gol": "1",
"goldois": "5",
"timedois": "Liverpool",
"imgdois": "https://futebolnatv.com.br/static/times/abe768c15fc134e24d933eef88e5d438.png",
"tempo": "Ao vivo PENALTIS",
"trans": "SPORTV(-RS), PREMIERE FC"
}]
really the way it worked, I will look for information on the internet to understand about this Domxpath, Thank you very much
– Rafael Silvestrini
That’s great, as it is new in the community I will guide how to proceed now, if you can, mark my answer as accepted, so my score increases and allows me to have access to more stackoverflow tools to contribute to the platform
– Ademir Mazer Jr - Nuno
Okay, can you give me some video on this case ? Thank you
– Rafael Silvestrini
Thank you. As for the video, unfortunately I don’t know any, but I’m creating content training on my channel, I can note it as content pending on DOM with PHP but I can’t guarantee you that I would do it this week, most likely in about 15 days. Follow me on Youtube that gets the video warning when available
– Ademir Mazer Jr - Nuno
Mazer dev ? followed your channel
– Rafael Silvestrini
Yes, but I think the Youtube search finds me by my name Ademir Mazer Junior
– Ademir Mazer Jr - Nuno