Is it at all possible to take a string like 'test.test2.test3', turn it into a reference and unset that index?
I've been trying to do it with pointers, and i've avoiding eval()'ling the code (This is for a templating engine, trying to get rid of persistance indexes outside of closures).
The code I have at the moment is:
Code: Select all
if(strpos($key, '.')) {
$found=true;
$parts=explode('.', $key);
$pointer=&$this->_vars[array_shift($parts)];
foreach($parts as $part)
if(isset($pointer[$part]))
$pointer=&$pointer[$part];
else break;
if($found) {
unset($pointer);
}
} else unset($this->_vars[$key]);Cheers,
Darkzaleus