Ques: Create a PHP program that adds two array. Here is given:
a. 2,4,6,8,10
b. 3,5,7,9,11
Solve:
<?php
$f_array=array(2,4,6,8,10);
$s_array=array(3,5,7,9,11);
for($i=0;$i<=4;$i++)
{
$r_array[]=$f_array[$i] + $s_array[$i];
echo "The answer is now result[$i]= " . "$r_array[$i]". "<br>";
}
?>
$f_array=array(2,4,6,8,10);
$s_array=array(3,5,7,9,11);
for($i=0;$i<=4;$i++)
{
$r_array[]=$f_array[$i] + $s_array[$i];
echo "The answer is now result[$i]= " . "$r_array[$i]". "<br>";
}
?>
No comments:
Post a Comment