i have a funny one here. I am trying to access an array property of an object. However to find that the object/ property are what i need i run a test that the object has the wanted property...if it does, then i need to access that property (always an array) and get the value:
Code: Select all
$roles = $user->roles;
foreach($roles as $rolekey=>$rolevalue)
{
//if the current object has the equivilant of this, : $node->field_california, then we will try to access it's nested array: node->field_california[0]['value']
$field = "field_".$rolevalue;
if(count($node->$field)>0)//we have the correct property
{
echo "<pre>Debug:" . print_r($node->$field[0]['value'],true) . "</pre>";
}
}