1 | <?php |
||
27 | final class ArrayUtil |
||
28 | { |
||
29 | /** |
||
30 | * Decompiles an array path string into an array of the path elements. |
||
31 | * |
||
32 | * For example |
||
33 | * |
||
34 | * $result = ArrayUtil::decompilePath('foo.doo.goo'); |
||
35 | * $result = ArrayUtil::decompilePath('foo[doo][goo]'); |
||
36 | * $result = ArrayUtil::decompilePath('[foo][doo][goo]'); |
||
37 | * |
||
38 | * // Outputs |
||
39 | * array( |
||
40 | * 'foo', |
||
41 | * 'doo', |
||
42 | * 'goo', |
||
43 | * ); |
||
44 | * |
||
45 | * @param string $path |
||
46 | * @return array |
||
47 | */ |
||
48 | public static function decompilePath($path) |
||
66 | |||
67 | /** |
||
68 | * Return a value from an array using an array path. |
||
69 | * |
||
70 | * If the $arrayPath's value doesn't exist within $array return $default. |
||
71 | * |
||
72 | * @param string $arrayPath |
||
73 | * @param array $array |
||
74 | * @param mixed $default A default value to use if _key_ isn't set in _array_. |
||
75 | * @return mixed |
||
76 | * @uses decompilePath To decompile $arrayPath. |
||
77 | */ |
||
78 | public static function get($arrayPath, array $array, $default = null) |
||
94 | |||
95 | /** |
||
96 | * Merges any number of arrays / parameters recursively, replacing entries with string keys with values from latter |
||
97 | * arrays. |
||
98 | * |
||
99 | * If the entry or the next value to be assigned is an array, then it automagically treats both arguments as an |
||
100 | * array. Numeric entries are appended, not replaced, if the value doesn't already exist in the merged array |
||
101 | * otherwise they're skipped. |
||
102 | * |
||
103 | * @return array The merged array |
||
104 | */ |
||
105 | public static function mergeRecursiveDistinct() |
||
136 | |||
137 | /** |
||
138 | * Tests if $array is an associative array. |
||
139 | * |
||
140 | * @param array $array |
||
141 | * @return boolean Returns true if just one key is a string, false otherwise. |
||
142 | */ |
||
143 | public static function isAssociative(array $array) |
||
147 | } |
||
148 |