Download the PHP package mitsuru793/array-helper-function without Composer
On this page you can find all versions of the php package mitsuru793/array-helper-function. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mitsuru793/array-helper-function
More information about mitsuru793/array-helper-function
Files in mitsuru793/array-helper-function
Package array-helper-function
Short Description This adds functions about array. If you feel like there few php built-in functions about array, this will be useful.
License MIT
Homepage https://github.com/mitsuru793/php-array-helper-function
Informations about the package array-helper-function
array-helper-function
This adds functions about array. If you feel like there few php built-in functions about array, this will be useful.
Installation
if you're using Composer to manage dependencies, you can include the following in your composer.json file:
Then, after running composer update or php composer.phar update, you can load the class using Composer's autoloading:
Functions
condtion
- is_empty_array
- is_full_array
- is_numeric_array
- is_numeric_array_recursive
- array_every
- array_any
each
- array_keys_recursive
- array_diff_key_recursive
- array_filter_recursive
access
- array_get
- array_set
- array_unset
- array_pick
Function detail
is_empty_array($value): bool
Finds whether a variable is a empty array.
return true when value is
[]
returns false when value is
- not array(ex:
0
,1
,true
,null
...) [1, 2]
[null]
[[], []]
is_full_array($value): bool
Finds whether a variable is a full array, so it's not empty array.
return true when value is
[1, 2]
[null]
[[], []]
returns false when value is
[]
- not array(ex:
0
,1
,true
,null
...)
is_numeric_array($value): bool
Finds whether all keys of variable are integer. This does not find deeply if element of $value
is array.
return true when value is
[]
[null]
[['k1' => 'v1'], 'v2]
returns false when value is
- not array(ex:
0
,1
,true
,null
...) ['k1' => 'v1', 'v2]
is_numeric_array_recursive($array): bool
Finds whether all keys of variable are integer deeply. This is like is_numeric_array
return true when value is
[]
[null]
returns false when value is
- not array(ex:
0
,1
,true
,null
...) ['k1' => 'v1', 'v2]
[['k1' => 'v1'], 'v2]
array_every(array $array, callable $test = null): bool
Verify that all elements of a $array
pass a given truth $test
.
If the $array
is empty, every will return true.
If the $test
is null, verify all them are truly.
array_any(array $array, callable $test = null): bool
Verify that a element of a $array
pass a given truth $test
.
If the $array
is empty, every will return false.
If the $test
is null, verify one is truly.
array_keys_recursive(array $array): array
This is like array_keys, but recursively. Return combinations of all keys.
array_diff_key_recursive(array $main, array $other): array
This is like array_diff_key, but recursively.
array_filter_recursive($array, callable $test = null): array
This is like array_filter, but recursively. The closure $test
is passed $key
by default.
array_get(array $array, $path, string $separator = '.')
Retrieves a value from a nested array. Notation of $path
is dot or array. If $path
is string, you can modify its separator from dot as 3rd argument.
array_set(array &$array, $path, $value, string $separator = '.'): void
Set a $value
within a nested array. Notation of $path
is dot or array. If $path
is string, you can modify its separator from dot as 3rd argument.
array_unset(array &$array, $path, string $separator = '.'): void
Set a $value
within a nested array. Notation of $path
is dot or array. If $path
is string, you can modify its separator from dot as 3rd argument.
array_pick(array &$array, array $values): array
Find whether $values
match elements of $array
strictly, and takes matched values from $array
. Has side effect and modify $array
.