You can create a variable to store the sum of the fees and add each fee to it in the foreach loop. Then, you can display the total sum outside of the loop. Here's an example:
In this example, we create a variable $totalFees and initialize it to 0 before the loop. Inside the loop, we add each fee to the total using the += operator. Finally, we display the total outside of the loop.