Returning More Than One Value
<?php
function addandsubtract ($firstvalue, $secondvalue){
$firstreturnvalue = ($firstvalue + $secondvalue);
$secondreturnvalue = ($firstvalue - $secondvalue);
$myarray = array ();
$myarray[0] = $firstreturnvalue;
$myarray[1] = $secondreturnvalue;
return $myarray;
}
$myarray = array ();
$myarray = addandsubtract (10, 3);
echo $myarray[0] . "<br />";
echo $myarray[1];
?>
Related examples in the same category