This is a homework question. I'm not asking for the full answer just some tips to keep moving along. I've been working on this for way to long. I'm multiplying the 3 dimensional array contains a list of people and the qty of tools they are buying I'm multiplying the item qty by an array of prices. The problem I'm having is that all three arrays are giving the same total instead of multipying each by a different factor. I've tried a few different approaches. I figured I need to use a while statement or if else to multiply each price to it's $key=>$value, but can't seem to get it to work.
<?php
$names = array(array( 'Name' => 'Tom',
'Hammers' => 3,
'Saws' => 2,
'Drills' => 2
),
array( 'Name' => 'Sue',
'Hammers' => 2,
'Saws' => 3,
'Drills' => 2
),
array( 'Name' => 'Steve',
'Hammers' => 2,
'Saws' => 2,
'Drills' =>2
)
);
$prices = array('Hammers'=>3.00,'Saws'=>2.50,'Drills'=>3.25);
for($array=0;$array<count($names);$array++){
foreach($names[$array] as $key=>$value)
{
$total= $names[0]["Hammers"] * $prices['Hammers'];
$total= $names[1]["Hammers"] * $prices['Hammers'];
$total= $names[2]["Hammers"] * $prices['Hammers'];
echo $key." = ".$value. "total".$total.'<br>';
}
}
?>