I've done the return an array trick. It works well. But something I had seen hinted at and hadn't tried until a few minutes ago is passing variable by reference.
Check this out:
$test1 = 1;
$test2 = 2;
echo $test1 . ' - ' . $test2 . '<p>';
makechange(&$test1, &$test2);
echo $test1 . ' - ' . $test2 . '<p>';
function makechange(&$var1, &$var2)
{
$var1++;
$var2 += 5;
} // end function makechange(&$var1, &$var2)
Results are:
1 - 2
2 - 7
So all you have to do is add '&' to the function's parameter list and when you call the function, add '&' to the variables you're passing in. You do not need the return statement. And when the function gets done, those variables you passed to the function will be updated.