ArrayLib deprecated
class ArrayLib (View source)
deprecated
Library of static methods for manipulating arrays.
Methods
Inverses the first and second level keys of an associative array, keying the result by the second level, and combines all first level entries within them.
Flattens a multi-dimensional array to a one level array without preserving the keys
Filter an array by keys (useful for only allowing certain form-input to be saved).
Determines if an array is associative by checking for existing keys via array_key_exists().
Recursively searches an array $haystack for the value(s) $needle.
Similar to array_map, but recurses when arrays are encountered.
Takes an multi dimension array and returns the flattened version.
Iterate list, but allowing for modifications to the underlying list.
Similar to shuffle, but retains the existing association between the keys and the values.
Insert a value into an array before another given value.
Insert a value into an array after another given value.
Details
__construct()
No description
static array
invert(array $arr)
deprecated
deprecated
Inverses the first and second level keys of an associative array, keying the result by the second level, and combines all first level entries within them.
Before:
After:
static array
valuekey($arr)
deprecated
deprecated
Return an array where the keys are all equal to the values.
static array
array_values_recursive(array $array)
deprecated
deprecated
Flattens a multi-dimensional array to a one level array without preserving the keys
static array
filter_keys($arr, $keys)
deprecated
deprecated
Filter an array by keys (useful for only allowing certain form-input to be saved).
static bool
is_associative(array $array)
deprecated
deprecated
Determines if an array is associative by checking for existing keys via array_key_exists().
static bool
in_array_recursive(mixed $needle, array $haystack, bool $strict = false)
deprecated
deprecated
Recursively searches an array $haystack for the value(s) $needle.
Assumes that all values in $needle (if $needle is an array) are at the SAME level, not spread across multiple dimensions of the $haystack.
static array
array_map_recursive($f, $array)
deprecated
deprecated
Similar to array_map, but recurses when arrays are encountered.
Actually only one array argument is supported.
static array
array_merge_recursive(array $array)
deprecated
deprecated
Recursively merges two or more arrays.
Behaves similar to array_merge_recursive(), however it only merges values when both are arrays rather than creating a new array with both values, as the PHP version does. The same behaviour also occurs with numeric keys, to match that of what PHP does to generate $_REQUEST.
static array
flatten(array $array, bool $preserveKeys = true, array $out = [])
deprecated
deprecated
Takes an multi dimension array and returns the flattened version.
static Generator
iterateVolatile(array $list)
deprecated
deprecated
Iterate list, but allowing for modifications to the underlying list.
Items in $list will only be iterated exactly once for each key, and supports items being removed or deleted. List must be associative.
static void
shuffleAssociative(array $array)
deprecated
deprecated
Similar to shuffle, but retains the existing association between the keys and the values.
Shuffles the array in place.
static array
insertBefore(array $array, mixed $insert, mixed $before, bool $strict = false, bool $splatInsertArray = false)
Insert a value into an array before another given value.
Does not preserve keys.
static array
insertAfter(array $array, mixed $insert, mixed $after, bool $strict = false, bool $splatInsertArray = false)
Insert a value into an array after another given value.
Does not preserve keys.