|
static | integerExplode ($delimiter, $string) |
|
static | trimExplode ($delimiter, $string, $onlyNonEmptyValues=false) |
|
static | arrayMergeRecursiveOverrule (array $firstArray, array $secondArray, $dontAddNewKeys=false, $emptyValuesOverride=true) |
|
static | randomizeArrayOrder (array $array) |
|
static | containsMultipleTypes (array $array) |
|
static | array_reduce (array $array, $function, $initial=null) |
|
static | getValueByPath (array &$array, $path) |
|
static | setValueByPath ($subject, $path, $value) |
|
static | unsetValueByPath (array $array, $path) |
|
static | sortKeysRecursively (array &$array, $sortFlags=null) |
|
static | convertObjectToArray ($subject) |
|
static | removeEmptyElementsRecursively (array $array) |
|
static | sortArrayWithIntegerKeys ($array) |
|
The array functions from good old GeneralUtility plus new code.
Definition at line 22 of file extbase/Classes/Utility/ArrayUtility.php.
static array_reduce |
( |
array |
$array, |
|
|
|
$function, |
|
|
|
$initial = null |
|
) |
| |
|
static |
Replacement for array_reduce that allows any type for $initial (instead of only integer)
- Parameters
-
array | $array | the array to reduce |
string | $function | the reduce function with the same order of parameters as in the native array_reduce (i.e. accumulator first, then current array element) |
mixed | $initial | the initial accumulator value |
- Returns
- mixed
Definition at line 157 of file extbase/Classes/Utility/ArrayUtility.php.
static arrayMergeRecursiveOverrule |
( |
array |
$firstArray, |
|
|
array |
$secondArray, |
|
|
|
$dontAddNewKeys = false , |
|
|
|
$emptyValuesOverride = true |
|
) |
| |
|
static |
Merges two arrays recursively and "binary safe" (integer keys are overridden as well), overruling similar values in the first array ($firstArray) with the values of the second array ($secondArray) In case of identical keys, ie. keeping the values of the second.
- Parameters
-
array | $firstArray | First array |
array | $secondArray | Second array, overruling the first array |
bool | $dontAddNewKeys | If set, keys that are NOT found in $firstArray (first array) will not be set. Thus only existing value can/will be overruled from second array. |
bool | $emptyValuesOverride | If set (which is the default), values from $secondArray will overrule if they are empty (according to PHP's empty() function) |
- Returns
- array Resulting array where $secondArray values has overruled $firstArray values
Definition at line 77 of file extbase/Classes/Utility/ArrayUtility.php.
static containsMultipleTypes |
( |
array |
$array | ) |
|
|
static |
static convertObjectToArray |
( |
|
$subject | ) |
|
|
static |
Recursively convert an object hierarchy into an associative array.
- Parameters
-
mixed | $subject | An object or array of objects |
- Exceptions
-
\InvalidArgumentException | |
- Returns
- array The subject represented as an array
Definition at line 279 of file extbase/Classes/Utility/ArrayUtility.php.
static getValueByPath |
( |
array & |
$array, |
|
|
|
$path |
|
) |
| |
|
static |
Returns the value of a nested array by following the specifed path.
- Parameters
-
array | &$array | The array to traverse as a reference |
array | string | $path | The path to follow. Either a simple array of keys or a string in the format 'foo.bar.baz' |
- Exceptions
-
\InvalidArgumentException | |
- Returns
- mixed The value found, NULL if the path didn't exist
Definition at line 175 of file extbase/Classes/Utility/ArrayUtility.php.
References elseif.
static integerExplode |
( |
|
$delimiter, |
|
|
|
$string |
|
) |
| |
|
static |
Explodes a $string delimited by $delimiter and casts each item in the array to (int). Corresponds to explode(), but with conversion to integers for all values.
- Parameters
-
string | $delimiter | Delimiter string to explode with |
string | $string | The string to explode |
- Returns
- array Exploded values, all converted to integers
Definition at line 33 of file extbase/Classes/Utility/ArrayUtility.php.
static randomizeArrayOrder |
( |
array |
$array | ) |
|
|
static |
Randomizes the order of array values. The array should not be an associative array as the key-value relations will be lost.
- Parameters
-
array | $array | Array to reorder |
- Returns
- array The array with randomly ordered values
Definition at line 112 of file extbase/Classes/Utility/ArrayUtility.php.
static removeEmptyElementsRecursively |
( |
array |
$array | ) |
|
|
static |
static setValueByPath |
( |
|
$subject, |
|
|
|
$path, |
|
|
|
$value |
|
) |
| |
|
static |
Sets the given value in a nested array or object by following the specified path.
- Parameters
-
array | \ArrayAccess | $subject | The array or ArrayAccess instance to work on |
array | string | $path | The path to follow. Either a simple array of keys or a string in the format 'foo.bar.baz' |
mixed | $value | The value to set |
- Exceptions
-
\InvalidArgumentException | |
- Returns
- array The modified array or object
Definition at line 202 of file extbase/Classes/Utility/ArrayUtility.php.
References elseif.
static sortArrayWithIntegerKeys |
( |
|
$array | ) |
|
|
static |
static sortKeysRecursively |
( |
array & |
$array, |
|
|
|
$sortFlags = null |
|
) |
| |
|
static |
Sorts multidimensional arrays by recursively calling ksort on its elements.
- Parameters
-
- Returns
- bool TRUE on success, FALSE on failure
- See Also
- asort()
Definition at line 260 of file extbase/Classes/Utility/ArrayUtility.php.
static trimExplode |
( |
|
$delimiter, |
|
|
|
$string, |
|
|
|
$onlyNonEmptyValues = false |
|
) |
| |
|
static |
Explodes a string and trims all values for whitespace in the ends. If $onlyNonEmptyValues is set, then all blank ('') values are removed.
- Parameters
-
string | $delimiter | Delimiter string to explode with |
string | $string | The string to explode |
bool | $onlyNonEmptyValues | If set, all empty values (='') will NOT be set in output |
- Returns
- array Exploded values
Definition at line 53 of file extbase/Classes/Utility/ArrayUtility.php.
static unsetValueByPath |
( |
array |
$array, |
|
|
|
$path |
|
) |
| |
|
static |
Unsets an element/part of a nested array by following the specified path.
- Parameters
-
array | $array | The array |
array | string | $path | The path to follow. Either a simple array of keys or a string in the format 'foo.bar.baz' |
- Exceptions
-
\InvalidArgumentException | |
- Returns
- array The modified array
Definition at line 232 of file extbase/Classes/Utility/ArrayUtility.php.
References elseif.