Voting

The Note You're Voting On

(v5.1.4)One cool thing about var_dump is it shows which variables are references (when dumping arrays), symbolized by '∫' for int/null, and by '&' for boolean/double/string/array/object. I don't know why the difference in symmmmbolism.After playing around I found a better way to implement detaching (twas by accident). var_dump can show what's going on.

$A['x'] = $A['x'];$A['y']=&detach();var_dump($A,$z);/* x returned to normal, y is on its own, z is still "hi"array(2) { ["x"]=> int(123) ["y"]=> NULL}*/?>

For detach to work you need to use '&' in the function declaration, and every time you call it.

Use this when you know a variable is a reference, and you want to assign a new value without effecting other vars referencing that piece of memory. You can initialize it with a new constant value, or variable, or new reference all in once step.