| Returning an array is like returning any other type of variable in
PHP. They work great as parameters too. Here's an example:
function add_fruit($a, $b) {
return array($a, $b, 'cranberry');
}
$fruits = add_fruit('apple','banana');
foreach ($fruits as $key => $fruit) {
print "$key : $fruit <br>";
}
0 : apple <br>
1 : banana <br>
2 : cranberry <br>
You can also use use 'global' to make variables (such as arrays)
available outside the scope of the function. So: |