Arrays
class Arrays
Array tools library.
Methods
Returns item from array or $default if item is not set.
Returns reference to array item.
Recursively appends elements of remaining keys from the second array to the first.
Searches the array for a given key and returns the offset if successful.
Inserts new array before item specified by key.
Inserts new array after item specified by key.
Renames key in array.
Returns array entries that match the pattern.
Returns flattened array.
Finds whether a variable is a zero-based integer indexed array.
Reformats table to associative tree. Path looks like 'field|field[]field->field=field'.
Normalizes to associative array.
Picks element from the array by key and return its value.
Tests whether some element in the array passes the callback test.
Tests whether all elements in the array pass the callback test.
Applies the callback to the elements of the array.
Details
at line 28
static mixed
get(array $arr, $key, $default = null)
Returns item from array or $default if item is not set.
at line 51
static mixed
getRef(array $arr, $key)
Returns reference to array item.
at line 68
static array
mergeTree(array $arr1, array $arr2)
Recursively appends elements of remaining keys from the second array to the first.
at line 84
static int|false
searchKey(array $arr, $key)
Searches the array for a given key and returns the offset if successful.
at line 95
static void
insertBefore(array $arr, $key, array $inserted)
Inserts new array before item specified by key.
at line 106
static void
insertAfter(array $arr, $key, array $inserted)
Inserts new array after item specified by key.
at line 118
static void
renameKey(array $arr, $oldKey, $newKey)
Renames key in array.
at line 133
static array
grep(array $arr, $pattern, $flags = 0)
Returns array entries that match the pattern.
at line 143
static array
flatten(array $arr, $preserveKeys = false)
Returns flattened array.
at line 158
static bool
isList($value)
Finds whether a variable is a zero-based integer indexed array.
at line 168
static array|stdClass
associate(array $arr, $path)
Reformats table to associative tree. Path looks like 'field|field[]field->field=field'.
at line 223
static array
normalize(array $arr, $filling = null)
Normalizes to associative array.
at line 241
static mixed
pick(array $arr, $key, $default = null)
Picks element from the array by key and return its value.
at line 261
static bool
some(array $arr, callable $callback)
Tests whether some element in the array passes the callback test.
at line 276
static bool
every(array $arr, callable $callback)
Tests whether all elements in the array pass the callback test.
at line 291
static array
map(array $arr, callable $callback)
Applies the callback to the elements of the array.
Traits
Static class.