To access your myproperty
array values try this:
$myObject->{$myproperty}[3]
Instead of:
$myObject->$myproperty[3]
These are referred to as Variables Variable, for more information visit: http://php.net/manual/en/language.variables.variable.php
The reason your echo
result was r
is because your $mypropery
value is mypropery
and you executed this echo $myObject->$myproperty[3]
which translate to saying you want the third character array keys value. Since arrays are zero based this means you will get the character r
as a result. Hope this clears up why your result was r
.