Hello,
I don't really know how to decribe this problem, so I'm sorry if the title is a bit unclear.
I got an object with array fields. I got the name of these fields stored in a variable and I want to reach an element in one of those array fields. e.g.
$field_name = 'array_field';
$object = new stdClass();
$object->array_field= array('this', 'is', 'an', 'array);
I know i can access the array with $object->$field_name
, but now I want to access a value by key in the array while accessing it with the $field_name
variable. e.g.(that obviously does not work) $object->$field_name[0]
many thanks!