floatval(isset($_POST['sitting']) ? $_POST['sitting'] : 0), 'office' => floatval(isset($_POST['office']) ? $_POST['office'] : 0), 'standing' => floatval(isset($_POST['standing']) ? $_POST['standing'] : 0), 'light_ex' => floatval(isset($_POST['light_ex']) ? $_POST['light_ex'] : 0), 'moderate_ex' => floatval(isset($_POST['moderate_ex']) ? $_POST['moderate_ex'] : 0), 'vigorous_ex' => floatval(isset($_POST['vigorous_ex']) ? $_POST['vigorous_ex'] : 0), ]; if (!in_array($gender, ['male', 'female'])) { $errors[] = 'Please select gender.'; } if ($age <= 0) { $errors[] = 'Please enter a valid age.'; } if ($weight <= 0) { $errors[] = 'Please enter a valid weight.'; } if ($height <= 0) { $errors[] = 'Please enter a valid height.'; } $sumHours = array_sum($hours); if ($sumHours > 24) { $errors[] = 'Sum of entered hours exceeds 24.'; } if (empty($errors)) { $pal = [ 'sitting' => 1.2, 'office' => 1.45, 'standing' => 1.85, 'light_ex' => 2.0, 'moderate_ex' => 3.0, 'vigorous_ex' => 4.0, 'sleep' => 0.95 ]; $sleepHours = max(0, 24 - $sumHours); $weighted = 0.0; foreach ($hours as $k => $h) { $weighted += $h * $pal[$k]; } $weighted += $sleepHours * $pal['sleep']; $avgPal = $weighted / 24.0; $bmr = calc_bmr($gender, $age, $weight, $height); $dailyCalories = $bmr * $avgPal; $result = [ 'bmr' => $bmr, 'avgPal' => $avgPal, 'dailyCalories' => $dailyCalories, 'dailyCalories_loss_400' => max(0, $dailyCalories - 400), 'sleepHours' => $sleepHours ]; } } ?> Kalorienrechner

Kalorienrechner

Enter hours spent per activity (total can be <= 24; remaining = sleep)

Results

BMR: kcal/day

Average PAL:

Sleep hours (calculated): h

Daily calories to maintain weight: kcal

To lose weight: about kcal (≈ -400 kcal)