1 | <?php |
||
9 | class ArrayUtils |
||
10 | { |
||
11 | use StaticClassTrait; |
||
12 | |||
13 | /** |
||
14 | * Test whether an array contains one or more keys by defined $type |
||
15 | * |
||
16 | * @param string $type the Type: string|int |
||
17 | * @param array $input |
||
18 | * @param bool $only |
||
19 | * @param bool $allow_empty Should an empty $input return true |
||
20 | * @return bool |
||
21 | */ |
||
22 | private static function hasKeysByType($type, array $input, $only = false, $allow_empty = false) |
||
33 | /** |
||
34 | * Test whether an array contains one or more string keys |
||
35 | * |
||
36 | * @param array $input |
||
37 | * @param bool $only |
||
38 | * @param bool $allow_empty Should an empty $input return true |
||
39 | * @return bool |
||
40 | */ |
||
41 | public static function hasStringKeys(array $input, $only = false, $allow_empty = false) |
||
45 | |||
46 | /** |
||
47 | * Test whether an array contains one or more integer keys |
||
48 | * |
||
49 | * @param array $input |
||
50 | * @param bool $only |
||
51 | * @param bool $allow_empty Should an empty $input return true |
||
52 | * @return bool |
||
53 | */ |
||
54 | public static function hasIntegerKeys(array $input, $only = false, $allow_empty = false) |
||
58 | |||
59 | /** |
||
60 | * Returns the value of the first found key-name |
||
61 | * |
||
62 | * @param array $input |
||
63 | * @param string[] $keys |
||
64 | * @param mixed $default |
||
65 | * @return mixed |
||
66 | */ |
||
67 | public static function findValueByKeys(array $input, array $keys, $default = null) |
||
78 | |||
79 | /** |
||
80 | * Flatten a multi-dimensional aray into a one dimensional array |
||
81 | * |
||
82 | * @param array $input |
||
83 | * @param string $preserve_keys |
||
84 | * @return array |
||
85 | */ |
||
86 | public static function flatten(array $input, $preserve_keys = false) |
||
96 | |||
97 | /** |
||
98 | * Rename a key inside a dimensional array |
||
99 | * |
||
100 | * @param array $input |
||
101 | * @param string old_key |
||
102 | * @param string new_key |
||
103 | * @return array |
||
104 | */ |
||
105 | public static function renameKey(array $input, $old_key, $new_key) |
||
116 | } |
||
117 |