I created this code to reference a Json array and built a list:
<?php
$json = file_get_contents('events.json');
$jsonArray = json_decode($json, true); // decode the JSON into an associative array
foreach ($jsonArray as $value) {
if (($value['active'] === 't') && ($value['fromDate'] >= $currentDate)) {
echo '<p>'.$value['title'].' '.$value['fromDate'].' - '.$value['toDate'].'</p>';
}
}
echo $currentDate;
?>
However, I can't figure out how to organize by a value in the Json file:
[
{
"active": "f",
"title": "My Third Event",
"city": "Robert Downey Jr.",
"ST": "Robert Downey Jr.",
"fromDate": "01/17",
"toDate": "01/20",
"website": "http://google.com",
"email": "[email protected]",
"logo": ""
},
{
"active": "t",
"title": "My First Event",
"city": "Robert Downey Jr.",
"ST": "Robert Downey Jr.",
"fromDate": "05/12",
"toDate": "01/20",
"website": "http://google.com",
"email": "[email protected]",
"logo": ""
}
]
I want to use "fromDate" to dynamically organize each entry when loaded. Any advise? FYI - i have reviewed the PHP manual and other SO entries, but i'm new to PHP and Ive not got my head totally wrapped around the concepts just yet. Thanks!
toDate?!