SubhanUllah Posted October 26, 2022 Report Posted October 26, 2022 $array = [1, 2, 3, 4, 6, 7, 8]; $from = 2; // array offset 1 $to = 4; // array offset 4 $sum = 0; for($i = $from; $i <= $to; $i++ ){ $sum = $sum + $array[$i]; } echo $sum; // 15 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.