public static
array
|
#
add( array $array, string $key, mixed $value )
Add an element to an array using "dot" notation if it doesn't exist.
Add an element to an array using "dot" notation if it doesn't exist.
Parameters
Returns
array
|
public static
array
|
#
build( array $array, callable $callback )
Build a new array using a callback.
Build a new array using a callback.
Parameters
Returns
array
|
public static
array
|
#
collapse( array|ArrayAccess $array )
Collapse an array of arrays into a single array.
Collapse an array of arrays into a single array.
Parameters
Returns
array
|
public static
array
|
#
divide( array $array )
Divide an array into two arrays. One with keys and the other with values.
Divide an array into two arrays. One with keys and the other with values.
Parameters
Returns
array
|
public static
array
|
#
dot( array $array, string $prepend = '' )
Flatten a multi-dimensional associative array with dots.
Flatten a multi-dimensional associative array with dots.
Parameters
Returns
array
|
public static
array
|
#
except( array $array, array|string $keys )
Get all of the given array except for a specified array of items.
Get all of the given array except for a specified array of items.
Parameters
Returns
array
|
public static
mixed
|
#
first( array $array, callable $callback = null, mixed $default = null )
Return the first element in an array passing a given truth test.
Return the first element in an array passing a given truth test.
Parameters
- $array
- $callback
- $default
Returns
mixed
|
public static
mixed
|
#
last( array $array, callable $callback = null, mixed $default = null )
Return the last element in an array passing a given truth test.
Return the last element in an array passing a given truth test.
Parameters
- $array
- $callback
- $default
Returns
mixed
|
public static
array
|
#
flatten( array $array )
Flatten a multi-dimensional array into a single level.
Flatten a multi-dimensional array into a single level.
Parameters
Returns
array
|
public static
|
#
forget( array & $array, array|string $keys )
Remove one or many array items from a given array using "dot" notation.
Remove one or many array items from a given array using "dot" notation.
Parameters
|
public static
mixed
|
#
get( array $array, string $key, mixed $default = null )
Get an item from an array using "dot" notation.
Get an item from an array using "dot" notation.
Parameters
Returns
mixed
|
public static
boolean
|
#
has( array $array, string $key )
Check if an item exists in an array using "dot" notation.
Check if an item exists in an array using "dot" notation.
Parameters
Returns
boolean
|
public static
array
|
#
only( array $array, array|string $keys )
Get a subset of the items from the given array.
Get a subset of the items from the given array.
Parameters
Returns
array
|
public static
array
|
#
pluck( array $array, string|array $value, string|array|null $key = null )
Pluck an array of values from an array.
Pluck an array of values from an array.
Parameters
Returns
array
|
protected static
array
|
#
explodePluckParameters( string|array $value, string|array|null $key )
Explode the "value" and "key" arguments passed to "pluck".
Explode the "value" and "key" arguments passed to "pluck".
Parameters
Returns
array
|
public static
mixed
|
#
pull( array & $array, string $key, mixed $default = null )
Get a value from the array, and remove it.
Get a value from the array, and remove it.
Parameters
Returns
mixed
|
public static
array
|
#
set( array & $array, string $key, mixed $value )
Set an array item to a given value using "dot" notation.
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.
Parameters
Returns
array
|
public static
array
|
#
sort( array $array, callable $callback )
Sort the array using the given callback.
Sort the array using the given callback.
Parameters
Returns
array
|
public static
array
|
#
where( array $array, callable $callback )
Filter the array using the given callback.
Filter the array using the given callback.
Parameters
Returns
array
|
public static
array
|
#
arToArray( CActiveRecord $model, boolean $withRelation = true, boolean $store = true )
Convert CActiveRecord implemetation to array, including all of it's relation.
Convert CActiveRecord implemetation to array, including all of it's relation.
Parameters
- $model
- Your model implementation.
- $withRelation
- Choose whether to fetch with your relation too or not.
- $store
- Store relation name in a temporary container. Useful to prefent infinite loop.
Returns
array
Link
|
public static
array
|
#
group( array $array )
Flip your array, mostly comes from stackable form like this:.
Flip your array, mostly comes from stackable form like this:.
<input name="first-name[]" />
<input name="last-name[]" />
[ "first-name" => ["Ganesha", "Krisan", "Farid"], "last-name" => ["Muharso", "Timur", "Hidayat"] ]
[
[ "first-name" => "Ganesha", "last-name" => "Muharso" ],
[ "first-name" => "Krisan", "last-name" => "Timur" ],
[ "first-name" => "Farid", "last-name" => "Hidayat" ]
]
foreach(Arr::group($personInput) as $person) { $model = new User;
$model->set($person)->save();
}
Parameters
Returns
array
|
public static
array
|
#
groupBy( array $array, Closure $callback )
Group array based on return from closure.
Group array based on return from closure.
Parameters
Returns
array
|
public static
array
|
#
pregOnly( string $pattern, array $input, integer $flags = 0 )
Get get array identified by a regex for it's index name.
Get get array identified by a regex for it's index name.
Parameters
Returns
array
|
public static
array
|
#
replaceKey( array $input, string|callable $search, string $replacement = '' )
Replace your array keys.
$array = [ ':type_address' => 'Foo', ':type_citizenship' => 'Bar', ':type_city' => 'Baz', ':type_country' => 'Qux' ]
Arr::replaceKey($array, ':type', 'user')
$array = [ 'user_address' => 'Foo', 'user_citizenship' => 'Bar', 'user_city' => 'Baz', 'user_country' => 'Qux' ]
Parameters
- $input
- $search
- $replacement
Returns
array
|
public static
array
|
#
replaceValue( array $input, string|callable $search, string $replacement = '' )
Replace your array value.
Replace your array value.
$header = [ ':type_address', ':type_citizenship', ':type_city', ':type_country' ]
Arr::replaceValue($header, ':type_')
$header = [ 'address', 'citizenship', 'city', 'country' ]
Parameters
- $input
- $search
- $replacement
Returns
array
|
public static
integer
|
#
depth( array $array )
Determine your multidimension array depth.
Determine your multidimension array depth.
Parameters
Returns
integer
|
public static
boolean
|
#
isEmpty( array $array )
Determine if array is empty, works on multidimension array.
Determine if array is empty, works on multidimension array.
Parameters
- $array
- Array you want to check whether it's empty or not
Returns
boolean
|