I want to build a string to reference an object.
I can reference is manually thus:
print_r($this->struct->parts[0]->parts[1]);
but if I build a string...
$string = "->parts[0]->parts[1]"
....and try to reference it thus...
print_r($this->struct{$string });
I get Fatal error : Cannot use object of type stdClass as array
Any thoughts?
I can reference is manually thus:
print_r($this->struct->parts[0]->parts[1]);
but if I build a string...
$string = "->parts[0]->parts[1]"
....and try to reference it thus...
print_r($this->struct{$string });
I get Fatal error : Cannot use object of type stdClass as array
Any thoughts?
Comment