Im trying to study Pointers in PHP, but there are few things I still dont understand..
This example works fine:
<?Php
function example(&$anything){
$anything[] = 'b';
}
$temp = array('a');
example($temp);
print_r($temp);
//Array ( [0] => a [1] => b )
?>
Now Here Im having problems..
<?Php
$temp = array('a');
function example(){
global $temp;
return $temp;
}
$something = &example();
$something[] = 'b';
print_r($temp);
//Array ( [0] => a )
?>
How can I make that "$temp" changes.. and returns "Array ( [0] => a [1] => b ) "?
I know that "$something = &$temp;" works.. But the idea is use the result of a functon