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
파일 보기 프로젝트 열기: neos/flow-development-collection 1 사용 예제들

공개 메소드들

메소드 설명
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