php - how sort & display data?
33
I have this code from a weather report
$url = ('https://www.yr.no/sted/Norge/Vestland/Bergen/Bergen/varsel.xml');
$feed = simplexml_load_file($url) or die('Can not connect to server');
$result = array();
foreach ($feed->forecast->tabular->time as $content) {
array_push($result, [ "from" => (string)$content['from'],
"to" => (string)$content['to'],
'symbol' => (string)$content->symbol['name'],
'temperature' => (string)$content->temperature['value'],
'windDirection' => (string)$content->windDirection['code'],
'windSpeed' => (string)$content->windSpeed['mps'],
]);
}
print_r($result)
printing an array
Example output:
Array ( [0] => Array ( [from] => 2020-02-02T21:00:00 [to] => 2020-02-03T00:00:00 [symbol] => Lettskyet [temperature] => 2 [windDirection] => ENE [windSpeed] => 2.0 ) [1] => Array ( [from] => 2020-02-03T00:00:00 [to] => 2020-02-03T06:00:00 [symbol] => Skyet [temperature] => 1 [windDirection] => E [windSpeed] => 2.1 ) [2] => Array ( [from] => 2020-02-03T06:00:00 [to] => 2020-02-03T12:00:00 [symbol] => Skyet [temperature] => 1 [windDirection] => E [windSpeed] => 2.4 )
How could I sort this data in a minimal and modern way?
maybe something like this:
I am quite unexperienced. Any help is appreciated!
Answer
Solution:
You can use table something like this. Just example: