Mastering Development

Notice: Array to string conversion in PHP Json problems

I’m very new to php I have been watching some youtube videos

I have a json file


and i want to display each name and ip address

this is my php file

$jsondata = file_get_contents("info.json");
$names = json_decode($jsondata, true);

foreach ($names as $user){
    echo $user['name']."<br/>";

    echo "IP:".$user['ip'];
    echo "<br/>";

//echo "<br/>"; 
echo "<pre>";
echo "</pre>";


but im getting the error

Notice: Array to string conversion in C:\xampp\htdocs\test\test.php on
line 13

and im not sure why any help would be appricated

Leave a Reply

Your email address will not be published. Required fields are marked *