Function definition with returning array value - PHP
#######################
PHP Code
#######################
<?phpfunction callmeforarray($a,$b)
{
$addition = $a + $b;
$minus = $a - $b;
$multiplication = $a * $b;
$division = $a / $b;
$modulus = $a % $b;
$returnvalue['sum'] = $addition."<br/>";
$returnvalue['min'] = $minus."<br/>";
$returnvalue['mul'] = $multiplication."<br/>";
$returnvalue['div'] = $division."<br/>";
$returnvalue['mod'] = $modulus."<br/>";
return $returnvalue;
}
echo "<hr/>";
$result = callmeforarray(30,5);
echo "Sum is : ". $result['sum'];
echo "Min is : ". $result['min'];
echo "mul is : ". $result['mul'];
echo "div is : ". $result['div'];
echo "mod is : ". $result['mod'];
$result = callmeforarray(34,2);
echo "Sum is : ". $result['sum'];
echo "Min is : ". $result['min'];
echo "mul is : ". $result['mul'];
echo "div is : ". $result['div'];
echo "mod is : ". $result['mod'];
echo "<hr/>";
?>
#######################
Output of the Code
#######################
Sum is : 35
Min is : 25
mul is : 150
div is : 6
mod is : 0
Sum is : 36
Min is : 32
mul is : 68
div is : 17
mod is : 0
Comments
Post a Comment