I've looked through a lot of answers and tried to get this to work but it's not printing. Could someone please help?
my json string:
$string=
'{“logpile”:[{
“machinemodel” :”Model#”,
“machineserial” :”Serial”,
“logs”:{
"data":[
{
“day” :”YYYY-MM-DD:hh:mm:ss”,
“code” :”OPTIME”,
“value” :”2345234”
},
{
“day” :”YYYY-MM-DD:hh:mm:ss”,
“code” :”ES01”,
“value” :”Fries”
}
]
}
}]}';
my attempt to decode:
$decoded = json_decode($string);
$comments = $decoded->logpile[0]->logs->data;
foreach($comments as $comment){
$name = $comment->day;
$message = $comment->value;
echo $name;
echo $value;
}