$startdatum = mktime(0, 0, 0, $in[month], $in[day], $in[year]);
$enddatum = mktime(0, 0, 0, $out[month], $out[day], $out[year]);
$enddatum += 86400;
$diff = $enddatum - $startdatum;
$mwfaktor_dp = round ($diff / 86400) * 4;
$rain_result = $db_pdo->prepare("SELECT rain_date, rain_mm, rain_time FROM rain WHERE (rain_timestamp between $startdatum AND $enddatum AND rain_place = 1) ORDER BY rain_date, rain_time");
$rain_result->execute();
$row = $rain_result->fetchAll(PDO::FETCH_ASSOC);
$i=0;
$dp_row = array();
foreach ($row as $row2) {
$dp_row[$row2[rain_date].$row2[rain_time]] = $row2[rain_mm];
}
$n = 0;
$ba = 0;
$s = 1;
$m=0;
$mw_array = array();
for ($i = $startdatum; $i < $enddatum; $i += 60) {
if ($s != $mwfaktor_dp) {
$mw += $dp_row[date("Y-m-dH:i:s", $i)];
$s++;
}
else {
$mw /= $mwfaktor_dp;
$m++;
$s = 1;
array_push ($mw_array, $mw);
unset ($mw);
}
$n++;
$vdate = date("Y-m-d", $i);
$vtime = date("H:i:s", $i);
if (!empty($dp_row[date("Y-m-dH:i:s", $i)])) {
$ba++;
}
}