Referring to this question ...
How do I access this object property with a hyphenated name?
... I have an additional one:
I want to access a json property that is saved in a variable ... something like ...
$var = '$obj->my-prop';
IF it would just be
$var = 'my-prop'
... I could solve the problem with the hyphenated name by calling it via
$obj->{$var}
which would lead to
$obj->{'my-prop'}
... like it is said in the preceding question.
BUT: My variable also contains the preceding object value ('$obj'). As calling it via {$var} leads to {'$obj->my-prop'}, which is invalid, the only way to solve it seams to be to explode('->',$var) and then concatenate it, which is a mess.
Does someone know the 'solution idéale'? :-)
EDIT: so the solution idéale of one has to solve the question whether to keep this literal object syntax by saving the variable as string that just looks(!) like an object. therefore the unpackPath function of h2ooooooo would be a proper one. In contrast to that to save that variable in a chain as array (as ToBe said) would open a more system appropriate way of processing data. To json_decode a string like 'a->b' is not possible though.