php object : get value of attribute by computed name
        Posted  
        
            by groovehunter
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by groovehunter
        
        
        
        Published on 2010-03-29T09:56:14Z
        Indexed on 
            2010/03/29
            10:03 UTC
        
        
        Read the original article
        Hit count: 479
        
hi simple question -
How do I access an attribute of an object by name, if i compute the name at runtime?
Ie. i loop over keys and want to get each value of the attributes "field_".$key
In python there is getattribute(myobject, attrname)
It works, of course, with eval("$val=$myobject->".$myattr.";"); but IMO this is ugly!!
TIA florian
© Stack Overflow or respective owner