Documentation

Arr
in package
Uses Macroable

Table of Contents

$macros  : array<string|int, mixed>
The registered string macros.
__call()  : mixed
Dynamically handle calls to the class.
__callStatic()  : mixed
Dynamically handle calls to the class.
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.
collapse()  : array<string|int, mixed>
Collapse an array of arrays into a single array.
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.
hasMacro()  : bool
Checks if macro is registered.
isAssoc()  : bool
Determines if an array is associative.
last()  : mixed
Return the last element in an array passing a given truth test.
macro()  : void
Register a custom macro.
mixin()  : void
Mix another object into the class.
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.
pull()  : mixed
Get a value from the array, and remove it.
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.
where()  : array<string|int, mixed>
Filter the array using the given callback.
wrap()  : array<string|int, mixed>
If the given value is not an array, wrap it in one.
explodePluckParameters()  : array<string|int, mixed>
Explode the "value" and "key" arguments passed to "pluck".

Properties

$macros

The registered string macros.

protected static array<string|int, mixed> $macros = []

Methods

__call()

Dynamically handle calls to the class.

public __call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

__callStatic()

Dynamically handle calls to the class.

public static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

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 $key, mixed $value) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
$key : string
$value : mixed
Return values
array<string|int, mixed>

collapse()

Collapse an array of arrays into a single array.

public static collapse(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
Return values
array<string|int, mixed>

crossJoin()

Cross join the given arrays, returning all possible permutations.

public static crossJoin(array<string|int, mixed> ...$arrays) : array<string|int, mixed>
Parameters
$arrays : array<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(array<string|int, mixed> $array[, string $prepend = '' ]) : array<string|int, mixed>
Parameters
$array : array<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 $keys) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
$keys : array<string|int, mixed>|string
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(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

flatten()

Flatten a multi-dimensional array into a single level.

public static flatten(array<string|int, mixed> $array[, int $depth = INF ]) : array<string|int, mixed>
Parameters
$array : array<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 $keys) : void
Parameters
$array : array<string|int, mixed>
$keys : array<string|int, mixed>|string
Return values
void

get()

Get an item from an array using "dot" notation.

public static get(ArrayAccess|array<string|int, mixed> $array, string $key[, mixed $default = null ]) : mixed
Parameters
$array : ArrayAccess|array<string|int, mixed>
$key : string
$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

hasMacro()

Checks if macro is registered.

public static hasMacro(string $name) : bool
Parameters
$name : string
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

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

macro()

Register a custom macro.

public static macro(string $name, object|callable $macro) : void
Parameters
$name : string
$macro : object|callable
Return values
void

mixin()

Mix another object into the class.

public static mixin(object $mixin) : void
Parameters
$mixin : object
Return values
void

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(array<string|int, mixed> $array, string|array<string|int, mixed> $value[, string|array<string|int, mixed>|null $key = null ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
$value : string|array<string|int, mixed>
$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>

pull()

Get a value from the array, and remove it.

public static pull(array<string|int, mixed> &$array, string $key[, mixed $default = null ]) : mixed
Parameters
$array : array<string|int, mixed>
$key : string
$default : mixed = null
Return values
mixed

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 ]) : mixed
Parameters
$array : array<string|int, mixed>
$number : int|null = null
Tags
throws
InvalidArgumentException
Return values
mixed

set()

Set an array item to a given value using "dot" notation.

public static set(array<string|int, mixed> &$array, string $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
$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) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
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|string|null $callback = null ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
$callback : callable|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) : array<string|int, mixed>
Parameters
$array : array<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>

wrap()

If the given value is not an array, 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
Return values
array<string|int, mixed>

Search results