I have the following JSON file
{
"ResultDate":"mydate",
"Tenant":"mytenant",
"Results":[
{
"Config":[
{
"Check":null,
"Object":null,
"ConfigItem":"Default",
"ConfigData":6,
"InfoText":null,
"Results":[
{
"Level":4,
"Value":null
},
{
"Level":5,
"Value":"Pass"
},
{
"Level":10,
"Value":"Fail"
},
{
"Level":15,
"Value":null
}
],
"Level":5
},
I now check if the file (JSON) exist and like to print the specific parts
//Check for every customer is the file exist
$filename = "../logs/" . $get_id_customer . "/myfile.json";
if (file_exists($filename)) {
$message = "The file $filename exists";
$filepath = $filename;
$json_string = file_get_contents($filepath);
$json = json_decode($json_string, true);
//$json = json_decode($json_string, true);
foreach($json['Results']['Config'] as $item) {
$ConfigItem = $item['ConfigItem'];
echo $ConfigItem;
}
But I don't get any results back. Have tried multiple different methods and examples but I dont get any result back from the JSON. Can anyone help me how to show the specific parts like configitem and configdata so I can workout the rest of my code?