index.php 835 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require __DIR__ . '/vendor/autoload.php';
  3. $url = 'https://www.yr.no/place/Norway/Troms/Tromsø/Tromsø/forecast_hour_by_hour.xml';
  4. $forecast = new App\Yr\Forecast($url);
  5. $range = $forecast->getTabular()->getBetween(
  6. $forecast->getSunset(), $forecast->getSunrise()->add(new \DateInterval('P1D'))
  7. );
  8. echo '<pre>';
  9. foreach ($range as $time)
  10. echo $time . "\n";
  11. echo "\n<hr />\n";
  12. foreach ($range->getVariations()->getData() as $data)
  13. echo sprintf("%s: %s\n", $data['time']->getFrom()->format("H:i"), join(", ", $data['entities']));
  14. $f = current(iterator_to_array($range->getIterator()));
  15. echo $f->getWindSpeed()->convertTo('ft/s');
  16. $stat = $range->getStatistics();
  17. echo $stat->getAverageTemperature();
  18. echo $stat->getAverageWindSpeed();
  19. echo "\n";
  20. foreach ($forecast->getCredit() as $c)
  21. echo $c . "\n";
  22. ?>