keys
TABLE OF CONTENTS
Get an array of the keys of an object
Definition
array keys(object $obj)
Returns an array containing the keys of the provided object. Note that, because JSON hashes are inherently unordered, the keys associated with $obj are inherently unordered.
Parameters
object $obj
Object to return the keys of.
Returns
array
Array of the keys of $obj.
Examples
Transformation
{
a: keys({name: 'Juliet', age:`13`}),
b: keys(`{}`),
c: keys(`false`), // Error
d: keys(['b', 'a', 'c']) // Error
}Result
{
"a": [
"name",
"age"
],
"b": []
}Returns an array containing the keys of the provided object. Note that because JSON hashes are inherently unordered, the keys associated with the provided object obj are inherently unordered. Implementations are not required to return keys in any specific order.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article