Arr
in package
Table of Contents
- accessible() : bool
- Determine whether the given value is array accessible.
- add() : array<string|int, mixed>
- Add an element to an array using "dot" notation if it doesn't exist.
- crossJoin() : array<string|int, mixed>
- Cross join the given arrays, returning all possible permutations.
- divide() : array<string|int, mixed>
- Divide an array into two arrays. One with keys and the other with values.
- dot() : array<string|int, mixed>
- Flatten a multi-dimensional associative array with dots.
- except() : array<string|int, mixed>
- Get all of the given array except for a specified array of keys.
- exists() : bool
- Determine if the given key exists in the provided array.
- first() : mixed
- Return the first element in an array passing a given truth test.
- flatten() : array<string|int, mixed>
- Flatten a multi-dimensional array into a single level.
- forget() : void
- Remove one or many array items from a given array using "dot" notation.
- get() : mixed
- Get an item from an array using "dot" notation.
- has() : bool
- Check if an item or items exist in an array using "dot" notation.
- hasAny() : bool
- Determine if any of the keys exist in an array using "dot" notation.
- isAssoc() : bool
- Determines if an array is associative.
- isList() : bool
- Determines if an array is a list.
- join() : string
- Join all items using a string. The final items can use a separate glue string.
- keyBy() : array<string|int, mixed>
- Key an associative array by a field or using a callback.
- last() : mixed
- Return the last element in an array passing a given truth test.
- map() : array<string|int, mixed>
- Run a map over each of the items in the array.
- only() : array<string|int, mixed>
- Get a subset of the items from the given array.
- pluck() : array<string|int, mixed>
- Pluck an array of values from an array.
- prepend() : array<string|int, mixed>
- Push an item onto the beginning of an array.
- prependKeysWith() : array<string|int, mixed>
- Prepend the key names of an associative array.
- pull() : mixed
- Get a value from the array, and remove it.
- query() : string
- Convert the array into a query string.
- random() : mixed
- Get one or a specified number of random values from an array.
- set() : array<string|int, mixed>
- Set an array item to a given value using "dot" notation.
- shuffle() : array<string|int, mixed>
- Shuffle the given array and return the result.
- sort() : array<string|int, mixed>
- Sort the array using the given callback or "dot" notation.
- sortRecursive() : array<string|int, mixed>
- Recursively sort an array by keys and values.
- toCssClasses() : string
- Conditionally compile classes from an array into a CSS class list.
- undot() : array<string|int, mixed>
- Convert a flatten "dot" notation array into an expanded array.
- where() : array<string|int, mixed>
- Filter the array using the given callback.
- whereNotNull() : array<string|int, mixed>
- Filter items where the value is not null.
- wrap() : array<string|int, mixed>
- If the given value is not an array and not null, wrap it in one.
- explodePluckParameters() : array<string|int, mixed>
- Explode the "value" and "key" arguments passed to "pluck".
Methods
accessible()
Determine whether the given value is array accessible.
public
static accessible(mixed $value) : bool
Parameters
- $value : mixed
Return values
bool —add()
Add an element to an array using "dot" notation if it doesn't exist.
public
static add(array<string|int, mixed> $array, string|int|float $key, mixed $value) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $key : string|int|float
- $value : mixed
Return values
array<string|int, mixed> —crossJoin()
Cross join the given arrays, returning all possible permutations.
public
static crossJoin(iteratable<string|int, mixed> ...$arrays) : array<string|int, mixed>
Parameters
- $arrays : iteratable<string|int, mixed>
Return values
array<string|int, mixed> —divide()
Divide an array into two arrays. One with keys and the other with values.
public
static divide(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Return values
array<string|int, mixed> —dot()
Flatten a multi-dimensional associative array with dots.
public
static dot(iteratable<string|int, mixed> $array[, string $prepend = '' ]) : array<string|int, mixed>
Parameters
- $array : iteratable<string|int, mixed>
- $prepend : string = ''
Return values
array<string|int, mixed> —except()
Get all of the given array except for a specified array of keys.
public
static except(array<string|int, mixed> $array, array<string|int, mixed>|string|int|float $keys) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $keys : array<string|int, mixed>|string|int|float
Return values
array<string|int, mixed> —exists()
Determine if the given key exists in the provided array.
public
static exists(ArrayAccess|array<string|int, mixed> $array, string|int $key) : bool
Parameters
- $array : ArrayAccess|array<string|int, mixed>
- $key : string|int
Return values
bool —first()
Return the first element in an array passing a given truth test.
public
static first(iteratable<string|int, mixed> $array[, callable|null $callback = null ][, mixed $default = null ]) : mixed
Parameters
- $array : iteratable<string|int, mixed>
- $callback : callable|null = null
- $default : mixed = null
Return values
mixed —flatten()
Flatten a multi-dimensional array into a single level.
public
static flatten(iteratable<string|int, mixed> $array[, int $depth = INF ]) : array<string|int, mixed>
Parameters
- $array : iteratable<string|int, mixed>
- $depth : int = INF
Return values
array<string|int, mixed> —forget()
Remove one or many array items from a given array using "dot" notation.
public
static forget(array<string|int, mixed> &$array, array<string|int, mixed>|string|int|float $keys) : void
Parameters
- $array : array<string|int, mixed>
- $keys : array<string|int, mixed>|string|int|float
Return values
void —get()
Get an item from an array using "dot" notation.
public
static get(ArrayAccess|array<string|int, mixed> $array, string|int|null $key[, mixed $default = null ]) : mixed
Parameters
- $array : ArrayAccess|array<string|int, mixed>
- $key : string|int|null
- $default : mixed = null
Return values
mixed —has()
Check if an item or items exist in an array using "dot" notation.
public
static has(ArrayAccess|array<string|int, mixed> $array, string|array<string|int, mixed> $keys) : bool
Parameters
- $array : ArrayAccess|array<string|int, mixed>
- $keys : string|array<string|int, mixed>
Return values
bool —hasAny()
Determine if any of the keys exist in an array using "dot" notation.
public
static hasAny(ArrayAccess|array<string|int, mixed> $array, string|array<string|int, mixed> $keys) : bool
Parameters
- $array : ArrayAccess|array<string|int, mixed>
- $keys : string|array<string|int, mixed>
Return values
bool —isAssoc()
Determines if an array is associative.
public
static isAssoc(array<string|int, mixed> $array) : bool
An array is "associative" if it doesn't have sequential numerical keys beginning with zero.
Parameters
- $array : array<string|int, mixed>
Return values
bool —isList()
Determines if an array is a list.
public
static isList(array<string|int, mixed> $array) : bool
An array is a "list" if all array keys are sequential integers starting from 0 with no gaps in between.
Parameters
- $array : array<string|int, mixed>
Return values
bool —join()
Join all items using a string. The final items can use a separate glue string.
public
static join(array<string|int, mixed> $array, string $glue[, string $finalGlue = '' ]) : string
Parameters
- $array : array<string|int, mixed>
- $glue : string
- $finalGlue : string = ''
Return values
string —keyBy()
Key an associative array by a field or using a callback.
public
static keyBy(array<string|int, mixed> $array, callable|array<string|int, mixed>|string $keyBy) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $keyBy : callable|array<string|int, mixed>|string
Return values
array<string|int, mixed> —last()
Return the last element in an array passing a given truth test.
public
static last(array<string|int, mixed> $array[, callable|null $callback = null ][, mixed $default = null ]) : mixed
Parameters
- $array : array<string|int, mixed>
- $callback : callable|null = null
- $default : mixed = null
Return values
mixed —map()
Run a map over each of the items in the array.
public
static map(array<string|int, mixed> $array, callable $callback) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $callback : callable
Return values
array<string|int, mixed> —only()
Get a subset of the items from the given array.
public
static only(array<string|int, mixed> $array, array<string|int, mixed>|string $keys) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $keys : array<string|int, mixed>|string
Return values
array<string|int, mixed> —pluck()
Pluck an array of values from an array.
public
static pluck(iteratable<string|int, mixed> $array, string|array<string|int, mixed>|int|null $value[, string|array<string|int, mixed>|null $key = null ]) : array<string|int, mixed>
Parameters
- $array : iteratable<string|int, mixed>
- $value : string|array<string|int, mixed>|int|null
- $key : string|array<string|int, mixed>|null = null
Return values
array<string|int, mixed> —prepend()
Push an item onto the beginning of an array.
public
static prepend(array<string|int, mixed> $array, mixed $value[, mixed $key = null ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $value : mixed
- $key : mixed = null
Return values
array<string|int, mixed> —prependKeysWith()
Prepend the key names of an associative array.
public
static prependKeysWith(array<string|int, mixed> $array, string $prependWith) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $prependWith : string
Return values
array<string|int, mixed> —pull()
Get a value from the array, and remove it.
public
static pull(array<string|int, mixed> &$array, string|int $key[, mixed $default = null ]) : mixed
Parameters
- $array : array<string|int, mixed>
- $key : string|int
- $default : mixed = null
Return values
mixed —query()
Convert the array into a query string.
public
static query(array<string|int, mixed> $array) : string
Parameters
- $array : array<string|int, mixed>
Return values
string —random()
Get one or a specified number of random values from an array.
public
static random(array<string|int, mixed> $array[, int|null $number = null ][, bool|false $preserveKeys = false ]) : mixed
Parameters
- $array : array<string|int, mixed>
- $number : int|null = null
- $preserveKeys : bool|false = false
Tags
Return values
mixed —set()
Set an array item to a given value using "dot" notation.
public
static set(array<string|int, mixed> &$array, string|int|null $key, mixed $value) : array<string|int, mixed>
If no key is given to the method, the entire array will be replaced.
Parameters
- $array : array<string|int, mixed>
- $key : string|int|null
- $value : mixed
Return values
array<string|int, mixed> —shuffle()
Shuffle the given array and return the result.
public
static shuffle(array<string|int, mixed> $array[, int|null $seed = null ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $seed : int|null = null
Return values
array<string|int, mixed> —sort()
Sort the array using the given callback or "dot" notation.
public
static sort(array<string|int, mixed> $array[, callable|array<string|int, mixed>|string|null $callback = null ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $callback : callable|array<string|int, mixed>|string|null = null
Return values
array<string|int, mixed> —sortRecursive()
Recursively sort an array by keys and values.
public
static sortRecursive(array<string|int, mixed> $array[, int $options = SORT_REGULAR ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $options : int = SORT_REGULAR
- $descending : bool = false
Return values
array<string|int, mixed> —toCssClasses()
Conditionally compile classes from an array into a CSS class list.
public
static toCssClasses(array<string|int, mixed> $array) : string
Parameters
- $array : array<string|int, mixed>
Return values
string —undot()
Convert a flatten "dot" notation array into an expanded array.
public
static undot(iteratable<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : iteratable<string|int, mixed>
Return values
array<string|int, mixed> —where()
Filter the array using the given callback.
public
static where(array<string|int, mixed> $array, callable $callback) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $callback : callable
Return values
array<string|int, mixed> —whereNotNull()
Filter items where the value is not null.
public
static whereNotNull(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Return values
array<string|int, mixed> —wrap()
If the given value is not an array and not null, wrap it in one.
public
static wrap(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Return values
array<string|int, mixed> —explodePluckParameters()
Explode the "value" and "key" arguments passed to "pluck".
protected
static explodePluckParameters(string|array<string|int, mixed> $value, string|array<string|int, mixed>|null $key) : array<string|int, mixed>
Parameters
- $value : string|array<string|int, mixed>
- $key : string|array<string|int, mixed>|null