@@ -80,7 +80,9 @@ Here, you can quickly get started by becoming familiar with each and every metho
8080* [ shuffle] ( #shufflearray-array-array )
8181* [ nth] ( #ntharray-array-int-a--1-int-b--0-array )
8282
83- ## ` getKeysArray(mixed $keys): array `
83+ # Common
84+
85+ ### ` getKeysArray(mixed $keys): array `
8486Transform variable into standarised array of keys
8587
8688** All ` $keys ` parameters are normalized using this method**
@@ -97,7 +99,7 @@ Arr::getKeysArray('key1.0.key2.1') -> ['key1', '0', 'key2', '1']
9799Arr::getKeysArray([null, 'key1', '', 'key2', 3.1415, 0]) -> ['key1', 'key2', 0]
98100```
99101
100- ## ` hasKeys(array $array, mixed $keys, bool $strict = false): bool `
102+ ### ` hasKeys(array $array, mixed $keys, bool $strict = false): bool `
101103Check if array has specified keys ( all required, when ` $strict ` is ` true ` )
102104
103105``` php
@@ -114,7 +116,7 @@ Arr::hasKeys($array, ['test', 'key1'], true) -> false
114116Arr::hasKeys($array, 'test') -> false
115117```
116118
117- ## ` getNestedElement(array|ArrayAccess $array, mixed $keys, mixed $default = null): mixed `
119+ ### ` getNestedElement(array|ArrayAccess $array, mixed $keys, mixed $default = null): mixed `
118120Get nested array element using specified keys or return ` $default ` value if it does not exists
119121
120122``` php
@@ -129,7 +131,7 @@ Arr::getNestedElement($array, ['nonexistent', 'key'], 'default') -> 'default'
129131Arr::getNestedElement($array, 'nonexistent.key.without.default') -> null
130132```
131133
132- ## ` setNestedElement(array $array, mixed $keys, mixed $value): array `
134+ ### ` setNestedElement(array $array, mixed $keys, mixed $value): array `
133135Set array element specified by keys to the desired value (create missing keys if necessary)
134136
135137``` php
@@ -153,7 +155,7 @@ Arr::setNestedElement($array, 'foo.[].foo', 'bar') ->
153155Arr::setNestedElement([], '[].[].[]', 'test') -> [ [ [ 'test' ] ] ]
154156```
155157
156- ## ` unpack(array $array, array $keys = []): array `
158+ ### ` unpack(array $array, array $keys = []): array `
157159Converts multidimensional array to map of keys concatenated by dot and corresponding values
158160
159161``` php
@@ -181,7 +183,9 @@ Arr::unpack($array) ->
181183]
182184```
183185
184- ## ` check(array $array, mixed|callable $condition, bool $strict = false): bool `
186+ # Validation
187+
188+ ### ` check(array $array, mixed|callable $condition, bool $strict = false): bool `
185189Check if every element of an array meets specified condition
186190
187191``` php
@@ -203,7 +207,7 @@ Arr::check($array, function ($value) { return $value; }, true) -> false
203207Arr::check($array, function ($value) { return $value === 1; }, true) -> true
204208```
205209
206- ## ` isEmpty(mixed $array): bool `
210+ ### ` isEmpty(mixed $array): bool `
207211Recursively check if all of array values match empty condition
208212
209213``` php
@@ -215,7 +219,7 @@ Arr::isEmpty([0 => [0], [], null, [false]) -> true
215219Arr::isEmpty([0 => [0 => 'a'], [], null, [false]]) -> false
216220```
217221
218- ## ` isAssoc(array $array, bool $strict = false): bool `
222+ ### ` isAssoc(array $array, bool $strict = false): bool `
219223Check if array is associative
220224
221225``` php
@@ -240,7 +244,7 @@ Arr::isAssoc([1, 2, 3], true) -> false
240244Arr::isAssoc([0 => 1, 1 => 2, 2 => 3], true) -> false
241245```
242246
243- ## ` isNumeric(array $array): bool `
247+ ### ` isNumeric(array $array): bool `
244248Check if array contain only numeric values
245249
246250``` php
@@ -249,7 +253,7 @@ Arr::isNumeric([1, '2', '3e10', 5.0002]) -> true
249253Arr::isNumeric([1, '2', '3e10', 5.0002, 'a']) -> false
250254```
251255
252- ## ` isUnique(array $array, bool $strict = false): bool `
256+ ### ` isUnique(array $array, bool $strict = false): bool `
253257Check if array values are unique
254258
255259``` php
@@ -259,7 +263,7 @@ Arr::isUnique([1, '1', true]) -> false
259263Arr::isUnique([1, '1', true], true) -> true
260264```
261265
262- ## ` isArrayOfArrays(array $array): bool `
266+ ### ` isArrayOfArrays(array $array): bool `
263267Check if every array element is array
264268
265269``` php
@@ -270,7 +274,11 @@ Arr::isArrayOfArrays([[], []]) -> true
270274Arr::isArrayOfArrays([1, 2 => []]) -> false
271275```
272276
273- ## ` map(array $array, callable $callback, int $mode = Arr::MAP_ARRAY_KEY_VALUE): array `
277+ # Manipulation
278+
279+ ## Map
280+
281+ ### ` map(array $array, callable $callback, int $mode = Arr::MAP_ARRAY_KEY_VALUE): array `
274282Applies a callback to the elements of given array. Arguments supplied to callback differs depending on selected ` $mode `
275283
276284* For backward compatibility using map(callable, array) is still possible but is deprecated and will issue appropriate warning*
@@ -328,7 +336,7 @@ Arr::map($array2, $mapValueKeysList, Arr::MAP_ARRAY_VALUE_KEYS_LIST) ->
328336]
329337```
330338
331- ## ` mapObjects(array $objects, string $method, ...$args): array `
339+ ### ` mapObjects(array $objects, string $method, ...$args): array `
332340Map array of object to values returned from objects method
333341
334342``` php
@@ -343,7 +351,9 @@ Arr::mapObjects($array, 'test') -> [1, 1, 1]
343351Arr::mapObjects($array, 'test', 2) -> [3, 3, 3]
344352```
345353
346- ## ` filterByKeys(array $array, mixed $keys, bool $exclude = false): array `
354+ ## Filter
355+
356+ ### ` filterByKeys(array $array, mixed $keys, bool $exclude = false): array `
347357Filter array values by preserving only those which keys are present in array obtained from $keys variable
348358
349359``` php
@@ -361,7 +371,7 @@ Arr::filterByKeys($array, [null, 0, '']) -> []
361371Arr::filterByKeys($array, [null, 0, ''], true) -> $array
362372```
363373
364- ## ` filterObjects(array $objects, string $method, ...$args): array `
374+ ### ` filterObjects(array $objects, string $method, ...$args): array `
365375Filter objects array using return value of specified method
366376
367377This method also filter values other than objects by standard boolean comparison
@@ -379,7 +389,9 @@ Arr::filterObjects($array, 'test') -> [$object, 'foo', $object]
379389Arr::filterObjects($array, 'test', false) -> ['foo']
380390```
381391
382- ## ` group(array $array, string|int $key): array `
392+ ## Group
393+
394+ ### ` group(array $array, string|int $key): array `
383395Group array of arrays by value of element with specified key
384396
385397``` php
@@ -426,7 +438,7 @@ Arr::group($array, 'key3') ->
426438Arr::group($array, 'key4') -> []
427439```
428440
429- ## ` groupObjects(array $objects, string $method, ...$args): array `
441+ ### ` groupObjects(array $objects, string $method, ...$args): array `
430442Group array of objects by value returned from specified method
431443
432444``` php
@@ -455,7 +467,9 @@ Arr::flattenSingle(Arr::groupObjects([$object1, $object2], 'test')) ->
455467]
456468```
457469
458- ## ` orderByKeys(array $array, mixed $keys, bool $appendUnmatched = true): array `
470+ ## Order
471+
472+ ### ` orderByKeys(array $array, mixed $keys, bool $appendUnmatched = true): array `
459473Order associative array according to supplied keys order
460474
461475``` php
@@ -494,7 +508,7 @@ Arr::orderByKeys($array, 'a.0.c', false) ->
494508]
495509```
496510
497- ## ` sortByKeys(array $array, mixed $keys = null, bool $assoc = true): array `
511+ ### ` sortByKeys(array $array, mixed $keys = null, bool $assoc = true): array `
498512Sort array of arrays using value specified by key(s)
499513
500514``` php
@@ -522,7 +536,9 @@ Arr::sortByKeys(['a' => 3, 'b' => 1, 'c' => 6]) -> ['b' => 1, 'a' => 3, 'c' => 6
522536Arr::sortByKeys(['a' => 3, 'b' => 1, 'c' => 6], null, false) -> [1, 3, 6]
523537```
524538
525- ## ` sum(array ...$arrays): array `
539+ ## Computations
540+
541+ ### ` sum(array ...$arrays): array `
526542Sum associative arrays by their keys into one array
527543
528544``` php
@@ -565,7 +581,7 @@ Arr::sum(...$arrays) ->
565581Arr::sum([null, '', false], ['1', true, 'test']) -> [1, 1, 0]
566582```
567583
568- ## ` diffObjects(array $array1, array $array2, array ...$arrays): array `
584+ ### ` diffObjects(array $array1, array $array2, array ...$arrays): array `
569585Differentiate two or more arrays of objects
570586
571587``` php
@@ -580,7 +596,9 @@ Arr::diffObjects([$object3, $object1, $object2], [$object3], [$object1, $object2
580596Arr::diffObjects([$object1], [$object3], [$object2], []) -> [$object1]
581597```
582598
583- ## ` flatten(array $array, ?int $depth = null, bool $assoc = false): array `
599+ ## Flattening
600+
601+ ### ` flatten(array $array, ?int $depth = null, bool $assoc = false): array `
584602Flatten array of arrays to a n-depth array
585603
586604``` php
@@ -650,7 +668,7 @@ Arr::flatten($array, null, true) ->
650668]
651669```
652670
653- ## ` flattenSingle(array $array): array `
671+ ### ` flattenSingle(array $array): array `
654672Flatten single element arrays (also nested single element arrays)
655673
656674``` php
@@ -685,7 +703,9 @@ Arr::flattenSingle([['a']]) -> ['a']
685703Arr::flattenSingle([]) -> []
686704```
687705
688- ## ` createMulti(array $keys, ?array $values = null): array `
706+ # Utilities
707+
708+ ### ` createMulti(array $keys, ?array $values = null): array `
689709 Create multidimensional array using either first param as config of keys and values or separate keys and values arrays
690710
691711``` php
@@ -736,7 +756,7 @@ Arr::createMulti([
736756Arr::createMulti([]) -> []
737757```
738758
739- ## ` forceArray(mixed $var, int $flag = self::FORCE_ARRAY_ALL): mixed `
759+ ### ` forceArray(mixed $var, int $flag = self::FORCE_ARRAY_ALL): mixed `
740760Make variable an array (according to flag settings)
741761
742762``` php
@@ -761,7 +781,7 @@ Arr::forceArray($object) -> [$object]
761781Arr::forceArray($object, Arr::FORCE_ARRAY_PRESERVE_ARRAY_OBJECTS) -> $object
762782```
763783
764- ## ` clone(array $array): array `
784+ ### ` clone(array $array): array `
765785Copy array and clone every object inside it
766786
767787``` php
@@ -791,7 +811,7 @@ $cloned[2]->counter -> 2
791811$cloned['nested']['object']->counter -> 2
792812```
793813
794- ## ` random(array $array, int $count = 1): mixed `
814+ ### ` random(array $array, int $count = 1): mixed `
795815Get random array value(s)
796816
797817``` php
@@ -813,7 +833,7 @@ Arr::random($array, 2) -> ['b' => 2, 'e' => 5]
813833Arr::random($array, 2) -> ['c' => 3, 'b' => 2]
814834```
815835
816- ## ` shuffle(array $array): array `
836+ ### ` shuffle(array $array): array `
817837Shuffle array preserving keys and returning new shuffled array
818838
819839``` php
@@ -844,7 +864,7 @@ Arr::shuffle($array) ->
844864]
845865```
846866
847- ## ` nth(array $array, int $A = 1, int $B = 0): array `
867+ ### ` nth(array $array, int $A = 1, int $B = 0): array `
848868Gets array elements with index matching condition $An + $B (preserving original keys)
849869
850870``` php
0 commit comments