arr¶
-
php\lib\arr Library for working with collections - arrays, iterators, etc.
Methods
__construct()¶private
- static
count($collection)¶Returns element count of the collection
Предупреждение
for iterators it will iterate all elements to return the result
Параметры:
- $collection –
array,Countable,IteratorРезультат:
intelement count
- static
has($collection, $value, $strict = false)¶
Параметры:
- $collection –
array,Traversable- $value –
mixed- $strict –
boolРезультат:
bool
- static
toArray($collection, $withKeys = false)¶Converts $collection to array
Параметры:
- $collection –
array,Iterator- $withKeys –
boolРезультат:
array
- static
of($collection, $withKeys = false)¶Alias of toArray()
Параметры:
- $collection –
array,Iterator- $withKeys –
bool,php\lib\falseРезультат:
array
- static
toList($collection)¶Example: items::toList([‘x’ => 10, 20], 30, [‘x’ => 50, 60]) -> [10, 20, 30, 50, 60]
Параметры:
- $collection –
Результат:
array
- static
keys($collection)¶Returns all keys of collection
Параметры:
- $collection –
array,IteratorРезультат:
array
- static
combine($keys, $values)¶Combines two collections to array.
Параметры:
- $keys –
array,Iterator- $values –
array,IteratorРезультат:
array,nullreturns null if size of arrays is not equals.
- static
map($collection, $callback)¶
Параметры:
- $collection –
array,Iterator- $callback –
callable
- static
flatten($collection, $maxLevel = -1)¶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.
Параметры:
- $collection –
array,Iterator- $maxLevel –
intРезультат:
array
- static
sort($collection, $comparator = null, $saveKeys = false)¶Sorts the specified list into ascending order
Параметры:
- $collection –
array,Iterator- $comparator –
callable- ($o1, $o2) -> int where -1 smaller, 0 equal, 1 greater- $saveKeys –
boolРезультат:
array
- static
sortByKeys($collection, $comparator = null, $saveKeys = false)¶Sorts the specified list into ascending order by keys
Параметры:
- $collection –
array,Iterator- $comparator –
callable- ($key1, $key2)- $saveKeys –
boolРезультат:
array
- static
peak($array)¶Returns the last element of array.
Параметры:
- $array –
Результат:
mixedlast value of array
- static
push($array, $values)¶
Параметры:
- $array –
array,ArrayAccess- $values –
- static
pop($array)¶
Параметры:
- $array –
arrayРезультат:
mixed
- static
shift($array)¶
Параметры:
- $array –
arrayРезультат:
mixed
- static
unshift($array, $values)¶
Параметры:
- $array –
array- $values –
- static
first($collection)¶
Параметры:
- $collection –
Traversable,arrayРезультат:
mixed
- static
firstKey($collection)¶
Параметры:
- $collection –
Traversable,arrayРезультат:
string,int,null
- static
reverse($array)¶
Параметры:
- $array –
arrayРезультат:
array