getKeysArray

Definition

1
Arr::getKeysArray(mixed $keys): array
Copied!

Description

Transform variable into standardised array of keys.
This method filters out any values that cannot be used as array key leaving only not empty strings and integers as seen in the example below.
All $keys arguments in other methods are normalized using this method

Examples

1
Arr::getKeysArray(0) -> [0]
2
3
Arr::getKeysArray(null) -> []
4
5
Arr::getKeysArray('key') -> ['key']
6
7
Arr::getKeysArray('key1.0.key2.1') -> ['key1', '0', 'key2', '1']
8
9
Arr::getKeysArray([null, 'key1', '', 'key2', 3.1415, 0]) -> ['key1', 'key2', 0]
Copied!
Last modified 2yr ago
Copy link