function to calculate sum between two indices in array
< ? php function sum ( $ arr , $ from , $ to ) { $ total = 0 ; for ( $ i = $ from ; $ i <= $ to ; $ i ++ ) $ total += $ arr [ $ i ] ; return $ total ; }