php - Accessing object property with variable -
i have object full of arrays, able change element in array code
$i = 0; $object->property[$i] = "some value";
however following code not change value , returns no errors.
$i = 0; $propertyname = "property"; $object->$propertyname[$i] = "some value";
try:
$i = 0; $propertyname = "property"; $object->{$propertyname}[$i] = "some value";
Comments
Post a Comment