0
Good morning.
I’m trying to consume a json in PHP but I’m having this problem:
Warning: Invalid argument supplied for foreach() in D: xampp htdocs api consumir index.php on line 7
Array Code - JSON
PHP code
<?php
$json_file = file_get_contents("http://localhost/api/carne/retornofim.php");
$json_str = json_decode($json_file, true);
$itens = $json_str['nodes'];
foreach ( $itens as $e )
{
echo $e['title']."<br>";
}
?>
http://phpfiddle.org/main/code/34uy-zf37
Att
now returned me NULL ?
– Rosivaldo Ribeiro
First you have to check if the url is working, put it directly in the http browser://localhost/api/meat/return.php, if it shows you the result is because it is working.
– Wictor Chaves
https://prnt.sc/j9fv8q JSON returns normal at http:/localhost/api/meat/return.php Now I need to pull JSON data to HTML
– Rosivaldo Ribeiro
I changed the answer, you put it like that, and yet you’re showing nothing?
– Wictor Chaves
http://prntscr.com/j9fy38 Me returned NULL.
– Rosivaldo Ribeiro
I put a code so you can debug why it’s not coming.
– Wictor Chaves