array array_sum get error message |
Results from the table:
Code: Array ( I want to sum an income_value value, so the results obtained are 36.00 I have tried this code but always get an error message: PHP Code: $sum = array();
Those aren't arrays, but objects inside an array.
So that would be: PHP Code: $sum = 0;
thank you very much for your help, but why are the results not decimal if using this method?
As there are no decimals to be added, it removes it.
If you wan't to display them with decimals, you need to use number_format. http://php.net/manual/en/function.number-format.php PHP Code: echo number_format($sum, 2);
But is there really no other way to add these decimal values? because I save a decimal value in the database.
I agree with what you explained above, but I prefer simpler code if there is one. |
Welcome Guest, Not a member yet? Register Sign In |