I tried to access an object property which has array form using string variable but not able do so when the string contains index selection. Take a look at this example.. what i was tring to do is to use $access3 like string
$dummy = new stdClass();
$dummy->testNormal = 'itemNormal';
$dummy->testArray = array('item1', 'item2');
$access1 = 'testNormal';
$access2 = 'testArray';
$access3 = 'testArray[0]';
echo 'try access1: ' . $dummy->{$access1} . '<br />';
echo 'try access2: ' . $dummy->{$access2}[0] . '<br />';
echo 'try access3: ' . $dummy->{$access3} . '<br />';
echo 'try direct: ' . $dummy->testArray[0] . '<br />';
The above code will return
try access1: itemNormal
try access2: item1
--- ERROR MESSAGE --
try access3: <-- does not contain anything because of error, my expectation is it will be "item1"
try direct: item1
Is this impossible with php?