index.php 627 B

123456789101112131415161718192021222324
  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. echo '<pre>';
  6. $range = $forecast->getTabular()->getBetween(
  7. $forecast->getSunset(), $forecast->getSunrise()->add(new \DateInterval('P1D'))
  8. );
  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. echo "\n";
  15. foreach ($forecast->getCredit() as $c)
  16. echo $c . "\n";
  17. ?>