how to get property name in php in foreach loop code example Example: php loop object keys echo $obj->name; echo $obj->age;