i am trying to Sum of variable in loop Parse PHP frame, its working but not getting expected result, i expect 1+1 is 2 but getting 11 meand its print both the variable insted of doing sum,

my Code is

```
    function amount()
    {

      $ip=getUserIP();        

     $crat_item= new ParseQuery("Cart");
     $crat_item->EqualTo("ipAddress", $ip);
     $crat_item->each(function($object){
                 GLOBAL $sum;
                  $total=0;
                  $a=$object->get('quantity');
                  $prMSP=intval($a);
                  $fMSP=array('msp' => $prMSP);

                  $sum=array_sum($fMSP);

                   $total+=$sum; 

                   echo "$total"; 

                    });           
    }

```