1 | <?php |
||
24 | final class ArrayObject extends CoreArrayObject |
||
25 | { |
||
26 | /** |
||
27 | * Adds possibility to pass multi-dimensional arrays to the constructor |
||
28 | * |
||
29 | * All arrays found among the values of the passed array will be transformed |
||
30 | * recursively to instances of ArrayObject. |
||
31 | * |
||
32 | * @param array $array Data array to initialize class with |
||
33 | */ |
||
34 | 6 | public function __construct(array $array) |
|
44 | |||
45 | /** |
||
46 | * Groups the array by one or more criteria defined via callback function |
||
47 | * |
||
48 | * Each element in the first dimension of the array is passed to the |
||
49 | * specified callback function and will be reordered in regard to the |
||
50 | * returned value. This can either be a string with the new key or an array |
||
51 | * with a stack of new keys. For an element <var>$e</var>, the callback |
||
52 | * return value <var>array('a', 'b')</var> translates to |
||
53 | * <var>$newArray['a']['b'][] = $e;</var>. |
||
54 | * |
||
55 | * Callback functions may take the element argument by reference and modify |
||
56 | * it during execution (e. g. to remove any fields that will be grouped by). |
||
57 | * |
||
58 | * @param callback $func Function to group by |
||
59 | * @return ArrayObject Provides fluent interface |
||
60 | */ |
||
61 | 4 | public function groupBy($func) |
|
101 | |||
102 | /** |
||
103 | * Adds usort as an instance method |
||
104 | * |
||
105 | * @param callback $cmp_function Function to sort by |
||
106 | * @return boolean |
||
107 | */ |
||
108 | 1 | public function usort($cmp_function) |
|
118 | |||
119 | /** |
||
120 | * |
||
121 | * @param array|callback $funcs |
||
122 | * @return ArrayObject Provides fluent interface |
||
123 | */ |
||
124 | 1 | public function usortm($funcs) |
|
128 | |||
129 | /** |
||
130 | * |
||
131 | * |
||
132 | * @param array|callback $funcs |
||
133 | * @return ArrayObject Provides fluent interface |
||
134 | */ |
||
135 | 1 | public function uasortm($funcs) |
|
136 | { |
||
137 | 1 | return $this->_uxsortm($funcs, 'a'); |
|
138 | } |
||
139 | |||
140 | /** |
||
141 | * |
||
142 | * @param array|callback $funcs |
||
143 | * @return ArrayObject Provides fluent interface |
||
144 | */ |
||
145 | 1 | public function uksortm($funcs) |
|
149 | |||
150 | /** |
||
151 | * Returns the multi-dimensional array structure with all instances of |
||
152 | * ArrayObject transformed to standard PHP arrays |
||
153 | * |
||
154 | * @return array Flattened array |
||
155 | */ |
||
156 | 3 | public function getArrayCopyRec() |
|
173 | |||
174 | /** |
||
175 | * Recursively applies all provided sorting functions to their corresponding |
||
176 | * dimension of the array |
||
177 | * |
||
178 | * @param ArrayObject $a Represents the current dimension |
||
179 | * in the active array branch |
||
180 | * @param array $sortFuncs Holds the specified sorting |
||
181 | * function for each dimension |
||
182 | * @param int $depth Current dimension |
||
183 | * @param string $sortMode Possible values: 'a', 'k', '' |
||
184 | * (= uasort, uksort, usort) |
||
185 | */ |
||
186 | 1 | private function _uxsortmRec( |
|
218 | |||
219 | /** |
||
220 | * Applies the first sorting function (if set) to the array's first |
||
221 | * dimension and starts the recursion to apply the other functions (if set) |
||
222 | * |
||
223 | * A sorting function is exactly the same as an usort callback. If you don't |
||
224 | * want to sort a specific dimension but one or more dimensions below it, |
||
225 | * pass <var>null</var> for each dimension that should be skipped. |
||
226 | * <var>array(null, null, $func)</var> would sort the third dimension but |
||
227 | * leave dimensions one and two untouched. |
||
228 | * |
||
229 | * @param array|callback $funcs Sorting function(s) to sort one or more |
||
230 | * dimensions of the array by |
||
231 | * @param string $sortMode Possible values: 'a', 'k', '' (= uasort, |
||
232 | * uksort, usort) |
||
233 | * @return ArrayObject Provides fluent interface |
||
234 | */ |
||
235 | 1 | private function _uxsortm($funcs, $sortMode = '') |
|
259 | } |
||
260 |