123456789101112131415161718192021222324252627282930313233343536 |
- <?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->getVariations()->getData() as $data) {
- echo $data['time']->getFrom()->format("H:i");
- }
- //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');
- echo "\n";
- $stat = $range->getStatistics();
- echo "\n";
- echo $stat->getAverageTemperature();
- echo "\n";
- echo $stat->getAverageWindSpeed();
- echo "\n";
- var_dump($stat->getAverageSymbols());
- var_dump($stat->getMostCommonSymbol());
- echo "\n";
- foreach ($forecast->getCredit() as $c)
- echo $c . "\n";
- ?>
|