Array (
[0] => Array (
[amount_paid] => 2050.00
)
[1] => Array (
[amount_paid] => 2050.00
)
[2] => Array (
[amount_paid] => 2050.00
)
[3] => Array (
[amount_paid] => 2050.00
)
[4] => Array (
[amount_paid] => 2050.00
)
[5] => Array (
[amount_paid] => 2050.00
)
[6] => Array (
[amount_paid] => 2050.00
)
[7] => Array (
[amount_paid] => 2050.00
)
[8] => Array (
[amount_paid] => 2050.00
)
[9] => Array (
[amount_paid] => 2050.00
)
[10] => Array (
[amount_paid] => 2050.00
)
[11] => Array (
[amount_paid] => 2050.00
)
[12] => Array (
[amount_paid] => 2050.00
)
[13] => Array (
[amount_paid] => 2050.00
)
)
I have this example of array in php. I want to sum up every 10 paid amount.
Example is sum index 0-9 , 10 - 19 and so on
What I tried is only for first 10 and I cant think how to handle for every 10 with dynamic number
for ($i = 0; $i < count($json); $i++) {
if ($i < 10) {
$subtotalamount += floatval($json[$i]['amount_paid']);
}
}