This is a simple question,I guess, but I couldn’t figure it out.
How do I get a total sum of sequential numbers in PHP Like 2,4,6,8,10 . . . .1000
Thank you for the help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
$sum = array_sum(explode(',', '2,4,6,8'));edit: if you just want the sum of even numbers within a range you could
$sum = array_sum(range(2,1000,2));