Considering I have a string entity.field_one.field_two.value
, how can I take this and construct a selection on an existing PHP object? Based on the string above I want to construct:
$output = $entity->field_one->field_two->value;
I'm aware that I can use variables like $entity->{$var1}
but considering I don't know how many dots there are going to be, I need to find a way to construct the whole thing dynamically.
Any help appreciated!