I have an object BIRD and then there is [0] through [10] and each number has a subheading like \"bug\" or \"beetle\" or \"gnat\" and a value for each of those.
I wan
If the 'object' is actually an associative array rather than a true object then array_keys()
will give you what you need without warnings or errors.
On the other hand, if your object is a true object, then you will get a warning if you try use array_keys()
directly.
You can extract the key-value pairs from an object as an associative array with get_object_vars()
, you can then get the keys from this with array_keys()
:
$keysFromObject = array_keys(get_object_vars($anObject));