Download the PHP package opxcore/array without Composer
On this page you can find all versions of the php package opxcore/array. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download opxcore/array
More information about opxcore/array
Files in opxcore/array
Package array
Short Description The OpxCore array utils.
License MIT
Informations about the package array
Array utils
Installing
Usage
Available methods:
For dot notation:
OpxCore\Arr\Arr::dot($array)
OpxCore\Arr\Arr::get($array, $key, $default)
OpxCore\Arr\Arr::set($array, $key, $value)
OpxCore\Arr\Arr::has($array, $keys)
OpxCore\Arr\Arr::forget($array, $keys)
OpxCore\Arr\Arr::pull($array, $key, $default)
OpxCore\Arr\Arr::push($array, $key, $value)
Regular arrays only:
OpxCore\Arr\Arr::only($array, $keys)
OpxCore\Arr\Arr::first($array, $callback, $default)
OpxCore\Arr\Arr::last($array, $callback, $default)
All $default
values are optional and could be callable
that returns value. By default, it is always null
.
Performance tips: All methods for manipulating with dot notation are optimised for performance on a dot notated keys. If you are care about performance much it is better to use regular array manipulations on non-dot notated arrays.
Making a dot notated array
Makes a dot notated array from any flat or multidimensional array.
Getting a value using dot notation
Gets a value from the array using dot notation. If the given key is not existing in the array, this function will return default value.
Setting a value using dot notation
Sets the value into the array for the given key using dot notation. Function modifies given array directly, but also returns modified array for convenient usage.
Determining a key (or keys) existence in the array
Determines if the given key (or several keys) are existing in the array.
Removing the values associated with the given keys
Removes the given key (or several keys given as an array) from the array. If any of keys are not existing in the array nothing happens. Function modifies given array directly, but also returns modified array for convenient usage.
Pulling the value from the array
Actually, this is combination of Arr::get()
and Arr::forget()
methods. This method
fetches the value and then removes it from the array. If the key is not exists in the
array, default value will be returned.
Pushing the value into the array
Pushes the value into the given key in array. If given key is not existing, it will be created and the value will be set as item of unassociated array. If the key is existing, value associated with this key will be casted as array and value will be added into it. Function modifies given array directly, but also returns modified array for convenient usage.