does anyone know how to loop an array & sum it? So i have an array with 3 values like in the picture below
and this is my code
Use laravel collection sum()
method instead of getting sum of array value in loop.
collect([1, 2, 3])->sum();
or use php array_sum()
method
array_sum([1, 2, 3, 4, 5]);