delete variable by reference
given the following code:
$tree = array();
$node =& $tree[];
// imagine tons of code that populates $node here
how can i delete $node by reference?
Using unset(), only the reference is destroyed and not the node in $tree
itself:
unset($node);
print_r($tree);
// outputs:
Array
(
[0] =>
)
Disclaimer: The above example is minified and isolated. Actually i'm
modifying a complex parser for a really ugly data structure. The code
heavily uses pointers as backreferences and i'd like to avoid refactoring
the whole code.
No comments:
Post a Comment