<?php
/*
for each month i
6monthAvg = round(
(
(
$profits[$i]
+((isset($profits[$i-1])) ? $profits[$i-1] : 0)
+((isset($profits[$i-2])) ? $profits[$i-2] : 0)
+((isset($profits[$i-3])) ? $profits[$i-3] : 0)
+((isset($profits[$i-4])) ? $profits[$i-4] : 0)
+((isset($profits[$i-5])) ? $profits[$i-5] : 0))/6),2);
for($i = 5, $length = count($months); $i < $length; $i++) {
echo round(array_sum(array_slice($months, $i, -6), 2);
}
foreach(array_chunk($months, 6) as $sixMonths){
if(count($sixMonths) == 6)
echo round(array_sum($sixMonths), 2);
else
echo "Not 6 months avilable";
}
*/
print_r(array_slice([1,2,3,4,5,6], 5, -6));
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- Array
(
)
preferences:
166.9 ms | 404 KiB | 183 Q