There are multiple response type from my service provider and that is why i created a config array like below.
$configArray = array(
'type_1' => array(
'name' => array('parent', 'user', 'profile', 'name', 'fullName')
),
'type_2' => array(
'name' => array('parent', 'person', 'info', 'basic', 'name')
)
);
So if the return type is 'type 1' object path of the variable 'name' is $obj->parent->user->profile->name->fullName and the same for type 2 is $obj->parent->person->basic->name
My question is, which is the correct implementation in php to set this object path dynamically ? Right now, my plan is to implement as below.
$path = '';
foreach($configArray[$type]['name'] as $chunks ){
if($path != ''){ $path .= '->'; }
$path .= $chunks;
}
It will be really helpful if someone can suggest a standard method.
Thanks in advance, Tismon Varghese