Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php sum two arrays

<?php
$x=[10,15,50];
$y=[20,30,40];
$count=count($x);

for ($j = 0; $j <$count; $j++) {
        $z[$j] = $x[$j] + $y[$j];
    }
echo  join(",", $x)."<br>";
echo  join(",", $y)."<br>";
echo  join(",", $z)."<br>";

//output
//10,15,50
//20,30,40
//30,45,90


?> 
 
PREVIOUS NEXT
Tagged: #php #sum #arrays
ADD COMMENT
Topic
Name
2+9 =