I'm scratching my head here. I'm a novice at this. I've been forcing myself to find this out by myself and not always relying on your help here. But I've ground my fingers on this one.
What I'm trying to do is to sort an array which I am getting from an external API (Link in code) and everything I try the entire list disappears or doesn't do anything. I've been reading over this documentation over and over and I can't seem to wrap my head around it
I'm trying to sort "realArrival" from value low to high.
Anywho here is my code:
<?php
$url = 'http://apis.is/flight?language=en&type=arrivals';
$json = file_get_contents($url);
$results = json_decode($json, TRUE);
echo '<table class="highlight responsive-table purple darken-4">';
echo "<tr>";
echo '<th>Date</th>';
echo '<th>Flight Number</th>';
echo '<th>Airline</th>';
echo '<th>From</th>';
echo '<th>Schedule. Time</th>';
echo '<th>Status</th>';
echo "</tr>";
foreach ($results['results'] as $item => $val) {
echo "<tr>";
echo '<td>'.$item = $val['date'].'</td>';
echo '<td>'.$item = $val['flightNumber'].'</td>';
echo '<td>'.$item = $val['airline'].'</td>';
echo '<td>'.$item = $val['from'].'</td>';
echo '<td>'.$item = $val['plannedArrival'].'</td>';
echo '<td>'.$item = $val['realArrival'].'</td>';
echo '</tr>';
}
echo '</table>';
?>
Thanks in advance!