I am trying to do something that’s quite complex (for me anyway) and I’ve got a point which has stopped me in my tracks.
In this project, you enter the weight of a box, and the percentage of materials held in that box. So for example, a box may have 10% of wood, 40% of plastic, and 50% of paper. The weights of the materials are held in the database as they dont change. So the value of 1% of wood is held in the database, as 1% of plastic and paper.
The controller should then take the percentage of material given, and then multiply it by the 1% value held in the database.
So far, this is my code:
foreach($wastestream as $ws) {
$genweight = $ws['Materialtype']['1pc'] * $ws['Valuegiven']['percent'];
}
And this gives the following values:
10% Wood = 97.5
40% Plastic = 100.4
50% Paper = 40.3
The problem I now have is that I have to add all of these variables together. So essentially what I want to do after it pumps out the values is to add them all up together, so:
97.5 + 100.4 + 40.3 = 238.2
What should I do?
Cheers!
I think I have misunderstood something, since it seems not complicated at all…
$total will hold the total value