PHP Класс Neos\Eel\Helper\ArrayHelper

The implementation uses the JavaScript specificiation where applicable, including EcmaScript 6 proposals. See https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array for a documentation and specification of the JavaScript implementation.
Наследование: implements Neos\Eel\ProtectedContextAwareInterface
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
allowsCallOfMethod ( string $methodName ) : boolean All methods are considered safe
concat ( array | mixed $array1, array | mixed $array2, array | mixed $array_ = null ) : array Concatenate arrays or values to a new array
first ( array $array ) : mixed Get the first element of an array
flip ( array $array ) : array Exchanges all keys with their associated values in an array
indexOf ( array $array, mixed $searchElement, integer $fromIndex = null ) : mixed
isEmpty ( array $array ) : boolean Check if an array is empty
join ( array $array, string $separator = ',' ) : string Join values of an array with a separator
keys ( array $array ) : array Get the array keys
last ( array $array ) : mixed Get the last element of an array
length ( array $array ) : integer Get the length of an array
pop ( array $array ) : array Removes the last element from an array
push ( array $array, mixed $element ) : array Insert one or more elements at the end of an array
random ( array $array ) : mixed Picks a random element from the array
reverse ( array $array ) : array Returns an array in reverse order
shift ( array $array ) : array Remove the first element of an array
shuffle ( array $array, boolean $preserveKeys = true ) : array Shuffle an array
slice ( array $array, string $begin, string $end = null ) : array Extract a portion of an indexed array
sort ( array $array ) : array Sorts an array
splice ( array $array, integer $offset, integer $length = 1, mixed $replacements = null ) : array Replaces a range of an array by the given replacements
unshift ( array $array, mixed $element ) : array Insert one or more elements at the beginning of an array

Описание методов

allowsCallOfMethod() публичный Метод

All methods are considered safe
public allowsCallOfMethod ( string $methodName ) : boolean
$methodName string
Результат boolean

concat() публичный Метод

Concatenate arrays or values to a new array
public concat ( array | mixed $array1, array | mixed $array2, array | mixed $array_ = null ) : array
$array1 array | mixed First array or value
$array2 array | mixed Second array or value
$array_ array | mixed Optional variable list of additional arrays / values
Результат array The array with concatenated arrays or values

first() публичный Метод

Get the first element of an array
public first ( array $array ) : mixed
$array array The array
Результат mixed

flip() публичный Метод

Note that the values of array need to be valid keys, i.e. they need to be either integer or string. If a value has several occurrences, the latest key will be used as its value, and all others will be lost.
public flip ( array $array ) : array
$array array
Результат array The array with flipped keys and values

indexOf() публичный Метод

public indexOf ( array $array, mixed $searchElement, integer $fromIndex = null ) : mixed
$array array
$searchElement mixed
$fromIndex integer
Результат mixed

isEmpty() публичный Метод

Check if an array is empty
public isEmpty ( array $array ) : boolean
$array array The array
Результат boolean TRUE if the array is empty

join() публичный Метод

Join values of an array with a separator
public join ( array $array, string $separator = ',' ) : string
$array array Array with values to join
$separator string A separator for the values
Результат string A string with the joined values separated by the separator

keys() публичный Метод

Get the array keys
public keys ( array $array ) : array
$array array The array
Результат array

last() публичный Метод

Get the last element of an array
public last ( array $array ) : mixed
$array array The array
Результат mixed

length() публичный Метод

Get the length of an array
public length ( array $array ) : integer
$array array The array
Результат integer

pop() публичный Метод

Note: This differs from the JavaScript behavior of Array.pop which will return the popped element. An empty array will result in an empty array again.
public pop ( array $array ) : array
$array array
Результат array The array without the last element

push() публичный Метод

Allows to push multiple elements at once:: Array.push(array, e1, e2)
public push ( array $array, mixed $element ) : array
$array array
$element mixed
Результат array The array with the inserted elements

random() публичный Метод

Picks a random element from the array
public random ( array $array ) : mixed
$array array
Результат mixed A random entry or NULL if the array is empty

reverse() публичный Метод

Returns an array in reverse order
public reverse ( array $array ) : array
$array array The array
Результат array

shift() публичный Метод

Note: This differs from the JavaScript behavior of Array.shift which will return the shifted element. An empty array will result in an empty array again.
public shift ( array $array ) : array
$array array
Результат array The array without the first element

shuffle() публичный Метод

Randomizes entries an array with the option to preserve the existing keys. When this option is set to FALSE, all keys will be replaced
public shuffle ( array $array, boolean $preserveKeys = true ) : array
$array array
$preserveKeys boolean Wether to preserve the keys when shuffling the array
Результат array The shuffled array

slice() публичный Метод

Extract a portion of an indexed array
public slice ( array $array, string $begin, string $end = null ) : array
$array array The array (with numeric indices)
$begin string
$end string
Результат array

sort() публичный Метод

The sorting is done first by numbers, then by characters. Internally natsort() is used as it most closely resembles javascript's sort(). Because there are no real associative arrays in Javascript, keys of the array will be preserved.
public sort ( array $array ) : array
$array array
Результат array The sorted array

splice() публичный Метод

Allows to give multiple replacements at once:: Array.splice(array, 3, 2, 'a', 'b')
public splice ( array $array, integer $offset, integer $length = 1, mixed $replacements = null ) : array
$array array
$offset integer Index of the first element to remove
$length integer Number of elements to remove
$replacements mixed Elements to insert instead of the removed range
Результат array The array with removed and replaced elements

unshift() публичный Метод

Allows to insert multiple elements at once:: Array.unshift(array, e1, e2)
public unshift ( array $array, mixed $element ) : array
$array array
$element mixed
Результат array The array with the inserted elements