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

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -