add summation $ and lifep : “$total_cost[$i]”+ $lifep[$i] on each age
<?php
if(isset($_POST['submit'])){
$gender = $_POST['gender'];
$age = $_POST['age'];
$hc = array(1000, 2000, 2500, 3000, 4000, 5000);
$life = array(100000, 100000, 500000, 750000, 1000000, 3000000);
$lifep = array(10000, 10000, 50000, 75000, 100000, 300000);
$costs = array(
"male" => array(
"age1" => array(100, 200, 250, 300, 400, 500),
"age2" => array(110, 220, 275, 330, 440, 550),
"age3" => array(130, 260, 325, 390, 520, 650),
"age4" => array(150, 300, 375, 450, 520, 750),
"age5" => array(200, 400, 500, 600, 800, 1000)
),
"female" => array(
"age1" => array(20, 40, 50, 60, 80, 100),
"age2" => array(24, 48, 60, 72, 96, 120),
"age3" => array(40, 80, 100, 120, 160, 200),
"age4" => array(150, 300, 375, 450, 520, 750),
"age5" => array(200, 400, 500, 600, 800, 1000)
)
);
$total_cost = $costs[$gender][$age];
echo "<table>";
echo "<tr><th>Health Care Costs for $gender ($age) and hc and life and lifep:</th></tr>";
for ($i=0; $i < count($hc); $i++) {
echo "<tr><td>$" . $total_cost[$i] . " hc " . $hc[$i] . " life " . $life[$i] . " lifep $" . ($lifep[$i] + $total_cost[$i]) . "</td></tr>";
}
echo "</table>";
}
?>