$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 = $rain === 0 && $wind < 2.5 ? 'Y' : $rain <= 0.3 && $wind < 3.1 ? 'M' : 'N'; $flyingIcon = $flying === 'Y' ? "🛩" : $flying === 'M' ? "🛩" : '⏚'; $riding = $rain === 0 && $temp > 15 ? 'Y' : $rain <= 0.3 && $temp > 10 ? 'M' : 'N'; $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 = []; $lastDay = $dayStr; } } $grouped[] = $dayGroup; require_once 'display.html.php';