Home › Forums › Back End › Pass array into function › Re: Pass array into function
February 27, 2011 at 8:32 am
#57919
Bob
Member
Let’s say you want to add up three numbers, which are the variables $var1, $var2 and $var3.
The following code would be the code for your function:
function myfunction($var1, $var2, $var3) {
$total = $var1 + $var2 + $var3;
echo $total;
}
?>
That adds them up and will output the total, if the function is used.
To use the function, you can use the code you posted above, and it will output 6. Hope this helps and is what you mean.