If the βobjectβ is actually an associative array and not a true object, then array_keys() will give you what you need without warning or error.
On the other hand, if your object is a true object, you will get a warning if you try to use array_keys() directly.
You can extract the key-value pairs from the object as an associative array using get_object_vars() , then you can get the keys from this using array_keys() :
$keysFromObject = array_keys(get_object_vars($anObject));
Bart b
source share