keys
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
{
a: keys({name: 'Juliet', age: `13`}),
b: keys(`{}`),
c: keys(`false`), // Error
d: keys(['b', 'a', 'c']) // Error
}
{
"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.
Updated 11 months ago