This tutorial will show you a simple method to sum values during a php loop.
Method 1:
Lets say we have an array or database result with various numbers and we would like to sum all numbers that are greater than 5. How would you do this? Well this example will show you just that. We first display our array with a list of numbers.
Our next set of codes is where the magic happens. We will run through the loop and sum values greater than 5 using '+='
That's it! This method can also be used to sum decimals.