php - Summing All Values Between a Number Range -


How can I add all the numbers of numbers using PHP?

For example:

  1-5 (1 + 2 + 3 + 4 + 5) = 15   

Need to use array_sum or array variation?

Multiple choices, here is 1.

  $ start = 1; $ End = 5; $ Sum = 0; For {$ sum = $ i; ($ I = $ start; $ i & lt; = $ end; $ i ++) } $ sum;    

Comments

Popular posts from this blog

How can I add a seperate action listener to all 14 of my buttons at once that can determine player turn?(java) -

php - Sorting an multidimension array using usort fails -

Simple file compression in C -