- 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): int
Returns 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): bool
arr::hasKey(array $array, mixed $key): bool
arr::toArray(array|\Traversable $collection, bool $withKeys): array
Converts $collection to array
arr::of(array|Iterator $collection, bool|false $withKeys): array
Alias of toArray()
arr::toList(mixed $collection, array $others): array
Example: items::toList(['x' => 10, 20], 30, ['x' => 50, 60]) -> [10, 20, 30, 50, 60]
arr::keys(iterable|array $collection): array
Returns all keys of collection
arr::values(array|Iterator $collection): array
Returns all values of collection
arr::combine(array|Iterator $keys, array|Iterator $values): array|null
Combines two collections to array.
arr::map(array|Iterator $collection, callable $callback): void
arr::flatten(array|Iterator $collection, int $maxLevel): array
Returns 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): array
Sorts the specified list into ascending order
arr::sortByKeys(array|Iterator $collection, callable $comparator, bool $saveKeys): array
Sorts the specified list into ascending order by keys
arr::peak(mixed $array): mixed
Returns the last element of array.
arr::push(array|ArrayAccess $array, mixed $values): void
arr::pop(array $array): mixed
arr::shift(array $array): mixed
arr::unshift(array $array, mixed $values): void
arr::first(Traversable|array $collection): mixed
arr::firstKey(Traversable|array $collection): string|int|null
arr::last(array $collection): mixed
Alias to peek().
arr::lastKey(array $collection): string|int|null
arr::reverse(array $array): array
arr::merge(array $array, array $others): array
__construct(): void