The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Pass array into function Re: Pass array into function


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.