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.
Converts array to object
Details
at line 29
static mixed
get(array $arr, string|int|array $key, $default = null)
Returns item from array or $default if item is not set.
at line 51
static mixed
getRef(array $arr, string|int|array $key)
Returns reference to array item.
at line 67
static array
mergeTree(array $arr1, array $arr2)
Recursively appends elements of remaining keys from the second array to the first.
at line 83
static int|null
searchKey(array $arr, $key)
Searches the array for a given key and returns the offset if successful.
at line 93
static void
insertBefore(array $arr, $key, array $inserted)
Inserts new array before item specified by key.
at line 103
static void
insertAfter(array $arr, $key, array $inserted)
Inserts new array after item specified by key.
at line 114
static void
renameKey(array $arr, $oldKey, $newKey)
Renames key in array.
at line 128
static array
grep(array $arr, string $pattern, int $flags = 0)
Returns array entries that match the pattern.
at line 137
static array
flatten(array $arr, bool $preserveKeys = false)
Returns flattened array.
at line 151
static bool
isList($value)
Finds whether a variable is a zero-based integer indexed array.
at line 161
static array|stdClass
associate(array $arr, $path)
Reformats table to associative tree. Path looks like 'field|field[]field->field=field'.
at line 215
static array
normalize(array $arr, $filling = null)
Normalizes to associative array.
at line 231
static mixed
pick(array $arr, string|int $key, $default = null)
Picks element from the array by key and return its value.
at line 250
static bool
some(array $arr, callable $callback)
Tests whether some element in the array passes the callback test.
at line 264
static bool
every(array $arr, callable $callback)
Tests whether all elements in the array pass the callback test.
at line 278
static array
map(array $arr, callable $callback)
Applies the callback to the elements of the array.
at line 293
static object
toObject(array $arr, object $obj)
Converts array to object
Traits
Static class.