The following code need to increase 2,9 during 10 times to achieve 27 in total. my code is just increase 2,9 every time and not respect the difference in the last item on array how can I solve it ? thank you.
result of the following code:
Array ( [0] => 2.9 [1] => 5.8 [2] => 8.7 [3] => 11.6 [4] => 14.5 [5] => 17.4 [6] => 20.3 [7] => 23.2 [8] => 26.1 [9] => 29 )
.
and it should be:
Array ( [0] => 2.9 [1] => 5.8 [2] => 8.7 [3] => 11.6 [4] => 14.5 [5] => 17.4 [6] => 20.3 [7] => 23.2 [8] => 26.1 [9] => 27 )
.
Code:
$horas_totais = 27;
$horario_dos_km = 9.3;
$getallours =[];
$rasteach = round( $horas_totais/$horario_dos_km, 1, PHP_ROUND_HALF_UP);
$tot='';
for($z=0;$z<=$horario_dos_km;$z++){
$tot += $rasteach;
$getallours[] = $tot;
}
$echo='<pre>';print_r($getallours);$echo='</pre>';