<?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));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename: /in/NAude
function name: (null)
number of ops: 9
compiled vars: none
line #* E I O op fetch ext return operands
-------------------------------------------------------------------------------------
28 0 E > INIT_FCALL 'print_r'
1 INIT_FCALL 'array_slice'
2 SEND_VAL <array>
3 SEND_VAL 5
4 SEND_VAL -6
5 DO_ICALL $0
6 SEND_VAR $0
7 DO_ICALL
8 > RETURN 1
Generated using Vulcan Logic Dumper, using php 8.0.0
preferences:
186.67 ms | 1393 KiB | 17 Q