sum of numbers with comma php

Solutions on MaxInterview for sum of numbers with comma php by the best coders in the world

showing results for - "sum of numbers with comma php"
Maely
28 Oct 2017
1<?php
2  $input = "1,2,3,4,5,6,7,8,9,10";
3    
4    $sum = 0;
5    
6    $input_arr = explode(",", $input);
7    
8    print_r(array_sum($input_arr)); #with array function
9    
10    // without array function
11    
12    $sum = 0;
13    foreach($input_arr as $v){
14    	//print "</br>".$v;
15		$sum = $sum + $v;    
16    }
17    print "</br>".$sum;   
18?>