So, I have an object with a structure similar to below, all of which are returned to me as stdClassobjects
$person->contact->phone;
$person->contact->email;
$person->contact->address->line_1;
$person->contact->address->line_2;
$person->dob->day;
$person->dob->month;
$person->dob->year;
$album->name;
$album->image->height;
$album->image->width;
$album->artist->name;
$album->artist->id;
etc. (note that these examples are not related to each other).
Is it possible to use variable variables to call contact->phoneas a direct property $person?
For instance:
$property = 'contact->phone';
echo $person->$property;
This will not work as it is and throws it away E_NOTICE, so I am trying to devise an alternative method for this.
Any ideas?
In response to responses related to proxy methods:
And I would like to exclude this object from the library and use it to populate a new object with an array map as follows:
array(
'contactPhone' => 'contact->phone',
'contactEmail' => 'contact->email'
);
and then go through the map to fill in the new facility. I guess I could lure the mapper ...