How to access an attribute of an object by name if I calculated the name at runtime?
For instance. I "field_" . $key over the keys and want to get each value of the "field_" . $key attributes "field_" . $key "field_" . $key .
There is getattribute(myobject, attrname) in python getattribute(myobject, attrname) .
It works, of course, with eval("$val=$myobject->".$myattr.";"); but IMO is ugly - is there a cleaner way to do this?
source share