assoc_to_keyval()
average()
delete()
filter_keys()
filter_prefixed()
filter_recursive()
filter_suffixed()
flatten()
flatten_assoc()
get()
in_array_recursive()
insert()
insert_after_key()
insert_after_value()
insert_assoc()
insert_before_key()
insert_before_value()
is_assoc()
is_multi()
key_exists()
keyval_to_assoc()
merge()
merge_assoc()
multisort()
next_by_key()
next_by_value()
pluck()
prepend()
previous_by_key()
previous_by_value()
reindex()
remove_prefixed()
remove_suffixed()
replace_key()
reverse_flatten()
search()
set()
sort()
subset()
sum()
to_assoc()
unique()
The Arr class provides a few nice functions for making dealing with arrays easier
package | Fuel |
---|---|
subpackage | Core |
assoc_to_keyval(array $assoc, string $key_field, string $val_field) : array
array
the array to convert
string
the field name of the key field
string
the field name of the value field
\InvalidArgumentException |
---|
array
average(array $array) : \Fuel\Core\number
array
the array containing the values
\Fuel\Core\number
the average valuedelete(array $array, mixed $key) : mixed
array
The search array
mixed
The dot-notated key or array of keys
mixed
filter_keys(array $array, array $keys, bool $remove) : array
array
the array to filter.
array
the keys to filter
bool
if true, removes the matched elements.
array
filter_prefixed(array $array, string $prefix, bool $remove_prefix) : array
array
the array to filter.
string
prefix to filter on.
bool
whether to remove the prefix.
array
filter_recursive(array $array, callback $callback) : array
array
the array to filter.
callback
the callback that determines whether or not a value is filtered
array
filter_suffixed(array $array, string $suffix, bool $remove_suffix) : array
array
the array to filter.
string
suffix to filter on.
bool
whether to remove the suffix.
array
flatten(array $array, string $glue, bool $reset, bool $indexed) : array
array
the array to flatten
string
what to glue the keys together with
bool
whether to reset and start over on a new array
bool
whether to flatten only associative array's, or also indexed ones
array
flatten_assoc(array $array, string $glue, bool $reset) : array
array
the array to flatten
string
what to glue the keys together with
bool
whether to reset and start over on a new array
array
get(array $array, mixed $key, string $default) : mixed
array
The search array
mixed
The dot-notated key or array of keys
string
The default value
mixed
in_array_recursive(mixed $needle, array $haystack, bool $strict) : bool
mixed
what to search for
array
array to search in
bool
bool
whether the needle is found in the haystack.insert(array $original, array | mixed $value, int $pos) : bool
array
the original array (by reference)
array
mixed
the value(s) to insert, if you want to insert an array it needs to be in an array itself
int
the numeric position at which to insert, negative to count from the end backwards
bool
false when array shorter then $pos, otherwise trueinsert_after_key(array $original, array | mixed $value, string | int $key, bool $is_assoc) : bool
array
the original array (by reference)
array
mixed
the value(s) to insert, if you want to insert an array it needs to be in an array itself
string
int
the key after which to insert
bool
whether the input is an associative array
bool
false when key isn't found in the array, otherwise trueinsert_after_value(array $original, array | mixed $value, string | int $search, bool $is_assoc) : bool
array
the original array (by reference)
array
mixed
the value(s) to insert, if you want to insert an array it needs to be in an array itself
string
int
the value after which to insert
bool
whether the input is an associative array
bool
false when value isn't found in the array, otherwise trueinsert_assoc(array $original, array $values, int $pos) : bool
array
the original array (by reference)
array
mixed
the value(s) to insert, if you want to insert an array it needs to be in an array itself
int
the numeric position at which to insert, negative to count from the end backwards
bool
false when array shorter then $pos, otherwise trueinsert_before_key(array $original, array | mixed $value, string | int $key, bool $is_assoc) : bool
array
the original array (by reference)
array
mixed
the value(s) to insert, if you want to insert an array it needs to be in an array itself
string
int
the key before which to insert
bool
whether the input is an associative array
bool
false when key isn't found in the array, otherwise trueinsert_before_value(array $original, array | mixed $value, string | int $search, bool $is_assoc) : bool
array
the original array (by reference)
array
mixed
the value(s) to insert, if you want to insert an array it needs to be in an array itself
string
int
the value after which to insert
bool
whether the input is an associative array
bool
false when value isn't found in the array, otherwise trueis_assoc(array $arr) : bool
array
the array to check
bool
true if its an assoc array, false if notis_multi(array $arr, bool $all_keys) : bool
array
the array to check
bool
if true, check that all elements are arrays
bool
true if its a multidimensional array, false if notkey_exists(array $array, mixed $key) : mixed
array
The search array
mixed
The dot-notated key or array of keys
mixed
keyval_to_assoc(array $array, string $key_field, string $val_field) : array
array
the array to convert
string
the field name of the key field
string
the field name of the value field
\InvalidArgumentException |
---|
array
merge() : array
merge_assoc() : array
multisort(array $array, array $conditions, bool $ignore_case) : array
array
collection of arrays/objects to sort
array
sorting conditions
bool
whether to sort case insensitive
array
next_by_key(array $array, string $key, bool $get_value, bool $strict) : mixed
array
the array containing the values
string
key of the current entry to use as reference
bool
if true, return the next value instead of the next key
bool
if true, do a strict key comparison
mixed
the value in the array, null if there is no next value, or false if the key doesn't existnext_by_value(array $array, string $value, bool $get_value, bool $strict) : mixed
array
the array containing the values
string
value of the current entry to use as reference
bool
if true, return the next value instead of the next key
bool
if true, do a strict key comparison
mixed
the value in the array, null if there is no next value, or false if the key doesn't existpluck(array $array, string $key, string $index) : array
array
collection of arrays to pluck from
string
key of the value to pluck
string
optional return array index key, true for original index
array
array of plucked valuesprepend(array $arr, string | array $key, mixed $value)
Will overwrite if the value exists.
array
the array to prepend to
string
array
the key or array of keys and values
mixed
the value to prepend
previous_by_key(array $array, string $key, bool $get_value, bool $strict) : mixed
array
the array containing the values
string
key of the current entry to use as reference
bool
if true, return the previous value instead of the previous key
bool
if true, do a strict key comparison
mixed
the value in the array, null if there is no previous value, or false if the key doesn't existprevious_by_value(array $array, string $value, bool $get_value, bool $strict) : mixed
array
the array containing the values
string
value of the current entry to use as reference
bool
if true, return the previous value instead of the previous key
bool
if true, do a strict key comparison
mixed
the value in the array, null if there is no previous value, or false if the key doesn't existreindex(array $arr) : array
array
the array to reindex
array
re-indexed arrayremove_prefixed(array $array, string $prefix) : array
array
the array to remove from
string
prefix to filter on
array
remove_suffixed(array $array, string $suffix) : array
array
the array to remove from
string
suffix to filter on
array
replace_key(array $source, array | string $replace, string $new_key) : array
array
the array containing the key/value combinations
array
string
key to replace or array containing the replacement keys
string
the replacement key
array
the array with the new keysreverse_flatten(array $array, string $glue) : array
array
flattened array
string
glue used in flattening
array
the unflattened arraysearch(array $array, mixed $value, string $default, bool $recursive, string $delimiter, bool $strict) : mixed
If $recursive is set to true, then the Arr::search() function will return a delimiter-notated key using $delimiter.
array
The search array
mixed
The searched value
string
The default value
bool
Whether to get keys recursive
string
The delimiter, when $recursive is true
bool
If true, do a strict key comparison
mixed
set(array $array, mixed $key, mixed $value) : void
array
The array to insert it into
mixed
The dot-notated key to set or array of keys
mixed
The value
sort(array $array, string $key, string $order, int $sort_flags) : array
access | public |
---|
array
The array to fetch from
string
The key to sort by
string
The order (asc or desc)
int
The php sort type flag
array
subset(array $array, array $keys, mixed $default) : array
Returns $default for missing keys, as with Arr::get()
array
the array containing the values
array
list of keys (or indices) to return
mixed
value of missing keys; default null
array
An array containing the same set of keys provided.sum(array $array, string $key) : \Fuel\Core\number
array
the array containing the values
string
key of the value to pluck
\Fuel\Core\number
the sum valueto_assoc(string $arr) : array | null
The array given must have an even number of elements or null will be returned.
Arr::to_assoc(array('foo','bar'));
string
the array to change
\BadMethodCallException |
---|
array
null
the new array or nullunique(array $arr) : array
It does not sort. First value is used.
array
the array to dedup
array
array with only de-duped values