Arr
class Arr (View source)
A collection of tools dealing with arrays
Methods
Determine whether the given value is array accessible.
Add an element to an array using "dot" notation if it doesn't exist.
Collapse an array of arrays into a single array.
Divide an array into two arrays. One with keys and the other with values.
Flatten a multi-dimensional associative array with dots.
Get all of the given array except for a specified array of items.
Determine if the given key exists in the provided array.
Get the first element in an array passing a given truth test.
Get the last element in an array passing a given truth test.
Remove one or many array items from a given array using "dot" notation.
Get an item from an array using "dot" notation.
Check if an item or items exist in an array using "dot" notation.
Determines if an array is associative.
Get a subset of the items from the given array.
Pluck an array of values from an array.
Push an item onto the beginning of an array.
Get a value from the array, and remove it.
Set an array item to a given value using "dot" notation.
Shuffle the given array and return the result.
Recursively sort an array by keys and values.
Get an item from an array or object using "dot" notation.
Details
at line 20
static bool
accessible(mixed $value)
Determine whether the given value is array accessible.
at line 33
static array
add(array $array, string $key, mixed $value)
Add an element to an array using "dot" notation if it doesn't exist.
at line 48
static array
collapse(array $array)
Collapse an array of arrays into a single array.
at line 66
static array
divide(array $array)
Divide an array into two arrays. One with keys and the other with values.
at line 78
static array
dot(array $array, string $prepend = '')
Flatten a multi-dimensional associative array with dots.
at line 100
static array
except(array $array, array|string $keys)
Get all of the given array except for a specified array of items.
at line 114
static bool
exists(ArrayAccess|array $array, string|int $key)
Determine if the given key exists in the provided array.
at line 131
static mixed
first(array $array, callable|null $callback = null, mixed $default = null)
Get the first element in an array passing a given truth test.
at line 160
static mixed
last(array $array, callable|null $callback = null, mixed $default = null)
Get the last element in an array passing a given truth test.
at line 176
static void
forget(array $array, array|string $keys)
Remove one or many array items from a given array using "dot" notation.
at line 221
static mixed
get(ArrayAccess|array $array, string $key, mixed $default = null)
Get an item from an array using "dot" notation.
at line 253
static bool
has(ArrayAccess|array $array, string|array $keys)
Check if an item or items exist in an array using "dot" notation.
at line 296
static bool
isAssoc(array $array)
Determines if an array is associative.
An array is "associative" if it doesn't have sequential numerical keys beginning with zero.
at line 310
static array
only(array $array, array|string $keys)
Get a subset of the items from the given array.
at line 323
static array
pluck(array $array, string|array $value, string|array|null $key = null)
Pluck an array of values from an array.
at line 371
static array
prepend(array $array, mixed $value, mixed $key = null)
Push an item onto the beginning of an array.
at line 390
static mixed
pull(array $array, string $key, mixed $default = null)
Get a value from the array, and remove it.
at line 409
static array
set(array $array, string $key, mixed $value)
Set an array item to a given value using "dot" notation.
If no key is given to the method, the entire array will be replaced.
at line 441
static array
shuffle(array $array)
Shuffle the given array and return the result.
at line 454
static array
sortRecursive(array $array)
Recursively sort an array by keys and values.
at line 479
static mixed
data_get(mixed $target, string|array $key, mixed $default = null)
Get an item from an array or object using "dot" notation.