I have parsed and decoded a json into a php file. The json is in a format similar to this:
{"name":"John Doe", "records":[{"sample": "sample","fields":{"date":"Sample Date","Sample Field":"Sample value", "id": "sampleid"}}
I have a lot of records that are similar to this in that file. I have been using a foreach
loop to return all of the date
fields. The loop looks something like:
$records = $records_json['records'];
foreach($records as $record) {
echo "<option>" . $record['fields']['date'] . "</option>";
}
Right now, this is returning all of the dates. However, there are a lot of duplicate dates, and I only want to return the unique dates (without duplicates). Is there a way to do this?