you can use links:
$s =& $x->a->b;
or, if you want to use the string approach, do it step by step:
function getRef($base, $str) {
$out = $base;
$parts = explode("->", $str);
foreach ($parts as $p) {
$out = $out->$p;
}
return $out;
}
getRef($x, "a->b");
nickf source
share