I am trying to decode a JSON file using PHP. This is the Code that I am using.
<?php
$content = file_get_contents('result.json');
$contendecoded = json_decode($content);
print_r($contendecoded);
foreach ($contendecoded as $each) {
# code...
echo '<li>' .$each->Receiver. '</li>';
}
?>
This is the result.json file
{"Sender":"254705537065","Receiver":"7528452889","Amount":"1","FName":"Martinique","AccessToken":"8XRTHN59NCHvUGAASGbK6IcCzYcn"},
{"Sender":"254705537065","Receiver":"6584238686","Amount":"2","FName":"Phillipines2","AccessToken":"O4wBFWPmFA8ayKGYahhpdCAW97mg"},
{"Sender":"254705537065","Receiver":"6584238686","Amount":"2","FName":"Phillipines2","AccessToken":"O4wBFWPmFA8ayKGYahhpdCAW97mg"},
{"Sender":"254705537065","Receiver":"6584238686","Amount":"36","FName":"Phillipines3","AccessToken":"O4wBFWPmFA8ayKGYahhpdCAW97mg"},
{"Sender":"254705537065","Receiver":"6584238686","Amount":"36","FName":"Phillipines3","AccessToken":"O4wBFWPmFA8ayKGYahhpdCAW97mg"}
I am getting this error
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\website\receive.php on line 8
The line 8 refereed by the error is
foreach ($contendecoded as $each) {
How do I solve this?