- class
arr(php\lib\arr) - package
std - source
php/lib/arr.php
Child Classes
Description
Library for working with collections - arrays, iterators, etc.
arr ::count()- Returns element count of the collectionarr ::has()arr ::hasKey()arr ::toArray()- Converts $collection to arrayarr ::of()- Alias of toArray()arr ::toList()- Example: items::toList(['x' => 10, 20], 30, ['x' => 50, 60]) -> [10, 20, 30, 50, 60]arr ::keys()- Returns all keys of collectionarr ::values()- Returns all values of collectionarr ::combine()- Combines two collections to array.arr ::map()arr ::flatten()- Returns a new array that is a one-dimensional flattening of this collection (recursively).arr ::sort()- Sorts the specified list into ascending orderarr ::sortByKeys()- Sorts the specified list into ascending order by keysarr ::peak()- Returns the last element of array.arr ::push()arr ::pop()arr ::shift()arr ::unshift()arr ::first()arr ::firstKey()arr ::last()- Alias to peek().arr ::lastKey()arr ::reverse()arr ::merge()
arr::count(array|Countable|Iterator $collection): intReturns element count of the collection
.. warning:: for iterators it will iterate all elements to return the result
arr::has(array|Traversable $collection, mixed $value, bool $strict): boolarr::hasKey(array $array, mixed $key): boolarr::toArray(array|\Traversable $collection, bool $withKeys): arrayConverts $collection to array
arr::of(array|Iterator $collection, bool|false $withKeys): arrayAlias of toArray()
arr::toList(mixed $collection, array $others): arrayExample: items::toList(['x' => 10, 20], 30, ['x' => 50, 60]) -> [10, 20, 30, 50, 60]
arr::keys(iterable|array $collection): arrayReturns all keys of collection
arr::values(array|Iterator $collection): arrayReturns all values of collection
arr::combine(array|Iterator $keys, array|Iterator $values): array|nullCombines two collections to array.
arr::map(array|Iterator $collection, callable $callback): voidarr::flatten(array|Iterator $collection, int $maxLevel): arrayReturns a new array that is a one-dimensional flattening of this collection (recursively). That is, for every element that is an collection, extract its elements into the new array. If the optional $maxLevel argument > -1 the level of recursion to flatten.
arr::sort(array|Iterator $collection, callable $comparator, bool $saveKeys): arraySorts the specified list into ascending order
arr::sortByKeys(array|Iterator $collection, callable $comparator, bool $saveKeys): arraySorts the specified list into ascending order by keys
arr::peak(mixed $array): mixedReturns the last element of array.
arr::push(array|ArrayAccess $array, mixed $values): voidarr::pop(array $array): mixedarr::shift(array $array): mixedarr::unshift(array $array, mixed $values): voidarr::first(Traversable|array $collection): mixedarr::firstKey(Traversable|array $collection): string|int|nullarr::last(array $collection): mixedAlias to peek().
arr::lastKey(array $collection): string|int|nullarr::reverse(array $array): arrayarr::merge(array $array, array $others): array__construct(): void