trouble getting the modified array of a user function
Posted: Mon Apr 13, 2009 2:07 pm
I have a basic function i made to add to an array.
The function will print_r out correctly. but i run into trouble when i try to get the new value outside of the function. I just get the original values, i've tried to return the array out of the function. but still nothing.
I'm sure i'm missing something here, but i'm not sure what?
Any Help would be Great.
Thanks
Oliver
Code: Select all
The array--
[color=#FF0000]$num=array(1, 4, 7);[/color]
function add($i, $array){
$array[]=$i;
echo "<pre>";
print_r($array);
echo "</pre>";
}
[color=#FF0000]calling the function[/color]
add(20, $num);I'm sure i'm missing something here, but i'm not sure what?
Any Help would be Great.
Thanks
Oliver