求和$ n次增加数学循环

so I am stuck on this for a couple of hours and i just cannot figure out how to do it.

Here is what output i want to accomplish:

if $n = 10 then we have sum ten times in a increment like this: 1+2+3+4+5+6+7+8+9+10

function summation($n) {

     $start = 1;
     $end = $n;
     $sum = 0;

     for($i = $start; $i <= $end; $i++) {

         $value ="+";
         echo ++$sum, $value;

     }                     

}

summation(5);
<?php
function summation($n) {

 $start = 1;
 $end = $n;
 $sum = 0;
 for($i = $start; $i <= $end; $i++) {
$sum+=$i; //add the $i varables up

}
echo $sum;
}

summation(10); //55

Ref: http://php.net/manual/fa/language.operators.assignment.php

Your code can be simplified:

$sum = array_sum(range(1, 10));