1234567891011121314151617181920212223242526272829303132 |
- <?php
- require __DIR__ . '/vendor/autoload.php';
- $url = 'https://www.yr.no/place/Norway/Troms/Tromsø/Tromsø/forecast_hour_by_hour.xml';
- $forecast = new App\Yr\Forecast($url);
- $range = $forecast->getTabular()->getBetween(
- $forecast->getSunset(), $forecast->getSunrise()->add(new \DateInterval('P1D'))
- );
- echo '<pre>';
- foreach ($range as $time)
- echo $time . "\n";
- echo "\n<hr />\n";
- foreach ($range->getVariations()->getData() as $data)
- echo sprintf("%s: %s\n", $data['time']->getFrom()->format("H:i"), join(", ", $data['entities']));
- $f = current(iterator_to_array($range->getIterator()));
- echo $f->getWindSpeed()->convertTo('ft/s');
- $stat = $range->getStatistics();
- echo $stat->getAverageTemperature();
- echo $stat->getAverageWindSpeed();
- echo "\n";
- foreach ($forecast->getCredit() as $c)
- echo $c . "\n";
- ?>
|