Array processing examples

   Arrays homework   Array homework

31, "Feb"=>28,"Mar"=>31,"Apr"=>30,"May"=>31,"Jun"=>30,        "Jul"=>31,"Aug"=>31,"Sep"=>30,"Oct"=>31, "Nov"=>30,"Dec"=>30);

foreach($months as $key => $value) { print "$key -> $value"; }

foreach($monthsAndDays as $key => $value) { print "$key -> $value"; }

foreach($months as $key => $value) { print "$value -> $monthsAndDays[$value]"; }

function sumDaysOfYear($months){ $sum = 0; foreach ($months as $key => $value) { $sum += $value; }  return $sum; }

echo "There are ". sumDaysOfYear($monthsAndDays). " days in the year";

?>  