How can I access values from an object property that is an array?
For example:
$myObject = new MyClass;
$myObject->myproperty = array(1 => 'English', 2 => 'French', 3 => 'German');
How can I get individual property values using the array keys from $myObject->mypropery? Using $myObject->myproperty[3] does not work.
EDIT: Using $myObject->myproperty[3] does in fact work. Where I find a problem is when doing it like this:
$myproperty = 'myproperty';
echo $myObject->$myproperty[3]
// result : 'r'
Yet if I do a var_dump on $myObject->$myproperty I see my array.
$myObject->$myPropertywill take the value from$myPropertyand use it as the property name. So if$myProperty = 'foo';, then it would be the same as saying$myObject->foo.