index.php 943 B

123456789101112131415161718192021222324252627282930313233343536
  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->getVariations()->getData() as $data) {
  10. echo $data['time']->getFrom()->format("H:i");
  11. }
  12. //echo sprintf("%s: %s\n", $data['time']->getFrom()->format("H:i"), join(", ", $data['entities']));
  13. $f = current(iterator_to_array($range->getIterator()));
  14. echo $f->getWindSpeed()->convertTo('ft/s');
  15. echo "\n";
  16. $stat = $range->getStatistics();
  17. echo "\n";
  18. echo $stat->getAverageTemperature();
  19. echo "\n";
  20. echo $stat->getAverageWindSpeed();
  21. echo "\n";
  22. var_dump($stat->getAverageSymbols());
  23. var_dump($stat->getMostCommonSymbol());
  24. echo "\n";
  25. foreach ($forecast->getCredit() as $c)
  26. echo $c . "\n";
  27. ?>