PHP Class 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.
Inheritance: implements Neos\Eel\ProtectedContextAwareInterface
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Méthodes publiques

Méthode Description
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

Method Details

allowsCallOfMethod() public méthode

All methods are considered safe
public allowsCallOfMethod ( string $methodName ) : boolean
$methodName string
Résultat boolean

concat() public méthode

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
Résultat array The array with concatenated arrays or values

first() public méthode

Get the first element of an array
public first ( array $array ) : mixed
$array array The array
Résultat mixed

flip() public méthode

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
Résultat array The array with flipped keys and values

indexOf() public méthode

public indexOf ( array $array, mixed $searchElement, integer $fromIndex = null ) : mixed
$array array
$searchElement mixed
$fromIndex integer
Résultat mixed

isEmpty() public méthode

Check if an array is empty
public isEmpty ( array $array ) : boolean
$array array The array
Résultat boolean TRUE if the array is empty

join() public méthode

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
Résultat string A string with the joined values separated by the separator

keys() public méthode

Get the array keys
public keys ( array $array ) : array
$array array The array
Résultat array

last() public méthode

Get the last element of an array
public last ( array $array ) : mixed
$array array The array
Résultat mixed

length() public méthode

Get the length of an array
public length ( array $array ) : integer
$array array The array
Résultat integer

pop() public méthode

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
Résultat array The array without the last element

push() public méthode

Allows to push multiple elements at once:: Array.push(array, e1, e2)
public push ( array $array, mixed $element ) : array
$array array
$element mixed
Résultat array The array with the inserted elements

random() public méthode

Picks a random element from the array
public random ( array $array ) : mixed
$array array
Résultat mixed A random entry or NULL if the array is empty

reverse() public méthode

Returns an array in reverse order
public reverse ( array $array ) : array
$array array The array
Résultat array

shift() public méthode

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
Résultat array The array without the first element

shuffle() public méthode

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
Résultat array The shuffled array

slice() public méthode

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
Résultat array

sort() public méthode

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
Résultat array The sorted array

splice() public méthode

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
Résultat array The array with removed and replaced elements

unshift() public méthode

Allows to insert multiple elements at once:: Array.unshift(array, e1, e2)
public unshift ( array $array, mixed $element ) : array
$array array
$element mixed
Résultat array The array with the inserted elements