View Single Post

  #1 (permalink)  
Old 05-12-2008
hi and hello
 
Posts: n/a
Default A question about php reference in array

a code segment:


$i = array('data'=>1000);

$arr = array('i'=>&$i);
$arr2 = $arr;

$i['data'] = 200;

print_r($arr);
print_r($arr2);

the result is:
Array
(
[i] => Array
(
[data] => 200
)

)
Array
(
[i] => Array
(
[data] => 200
)

)

This means the change of variable $i effects the $arr2 which is a copy
of $arr. Some one knows?

Reply With Quote