Hi I am trying to push values from the input into the array. I am a beginner in php and this is my assignment. I trying to make a schedule Like
Mondays = this amount of hours Tuesday = this amount of hours and etc
But I gotten confused during the process.
<?php
if (isset($_POST['submit'])){
$hours =array();
$hours[] =$_POST['mod1'];
$hours[] =$_POST['mod2'];
$hours[] =$_POST['mod3'];
$hours[] =$_POST['tues1'];
$hours[] =$_POST['tues2'];
$hours[] =$_POST['tues3'];
$hours[] =$_POST['wed1'];
$hours[] =$_POST['wed2'];
$hours[] =$_POST['wed3'];
$wkday = array("Monday" => 0, "Tuesday" => 0, "Wednesday" => 0);
$i = 0;
foreach ($hours as $value){
if(i<3){
$wkday[Monday] = $wkday[Monday] + $value;
} else if(i<6){
$wkday[Tuesday] = $wkday[Tuesday] + $value;
} else if(i<9){
$wkday[Wednesday] = $wkday[Wednesday] + $value;
}
$i++;
}
foreach($wkday as $key => $value) {
echo "Day: $key; Hours Worked: $value <br /> \n";
}
}
?>