$data->city->name . ', ' . $data->city->country, 'population' => $data->city->population, 'sunrise' => date('H:i:s', $data->city->sunrise), 'sunset' => date('H:i:s', $data->city->sunset) ]; $icons = [ //'01d' => "&#D83C;&#DF1E;", '01d' => '🌞', '01n' => '🌚', '02d' => "🌤", '02n' => "🌤", '03d' => "🌥", '03n' => "🌥", '04d' => "☁", '04n' => "☁", '09d' => "🌦", '09n' => "🌦", '10d' => "🌧", '10n' => "🌧", '11d' => "🌩", '11n' => "🌩", '13d' => "⛄", '13n' => "⛄", '50d' => "🌫", '50n' => "🌫" ]; $list = []; foreach ($data->list as $line) { $temp = $line->main->temp - 273.15; $date = date('D. d.m. H:i', $line->dt); $icon = $icons[$line->weather[0]->icon]; $rainArr = (array) ($line->rain ?? []); $snowArr = (array) ($line->snow ?? []); $rain = ($rainArr['3h'] ?? 0) + ($snowArr['3h'] ?? 0); $wind = $line->wind->speed; $flying = 'N'; if ($rain === 0 && $wind < 2.5) { $flying = 'Y'; } elseif ($rain <= 0.3 && $wind < 3.1) { $flying = 'M'; } $flyingIcon = $flying === 'Y' ? "🛩" : $flying === 'M' ? "🛩" : '⏚'; $riding = 'N'; if ($rain === 0 && $temp > 15) { $riding = 'Y'; } elseif ($rain <= 0.3 && $temp > 10) { $riding = 'M'; } $ridingIcon = $riding === 'Y' ? "🏍" : $riding === 'M' ? "🏍" : "🚳"; $list[] = [ 'temp' => $temp, 'date' => $date, 'icon' => $icon, 'rain' => $rain, 'wind' => $wind, 'flying' => $flying, 'flyingIcon' => $flyingIcon, 'riding' => $riding, 'ridingIcon' => $ridingIcon ]; } $lastDay = substr($list[0]['date'], 0, 11); $dayGroup = []; $grouped = []; foreach($list as $line) { $dayStr = substr($line['date'], 0, 11); if ($dayStr === $lastDay) { $dayGroup[] = $line; } else { $grouped[] = $dayGroup; $dayGroup = [$line]; $lastDay = $dayStr; } } $grouped[] = $dayGroup; require_once 'display.html.php';