ArrayLib
class ArrayLib
Library of static methods for manipulating arrays.
Methods
Inverses the first and second level keys of an associative array, keying the result by the second level, and combines all first level entries within them.
Return an array where the keys are all equal to the values.
No description
Filter an array by keys (useful for only allowing certain form-input to be saved).
Determines if an array is associative by checking for existing keys via array_key_exists().
Recursively searches an array $haystack for the value(s) $needle.
Similar to array_map, but recurses when arrays are encountered.
Recursively merges two or more arrays.
Takes an multi dimension array and returns the flattened version.
Details
at line 47
static array
invert(array $arr)
Inverses the first and second level keys of an associative array, keying the result by the second level, and combines all first level entries within them.
Before:
After:
at line 69
static array
valuekey($arr)
Return an array where the keys are all equal to the values.
at line 76
static
array_values_recursive($arr)
at line 102
static array
filter_keys($arr, $keys)
Filter an array by keys (useful for only allowing certain form-input to be saved).
at line 122
static boolean
is_associative(array $arr)
Determines if an array is associative by checking for existing keys via array_key_exists().
at line 148
static boolean
in_array_recursive(mixed $needle, array $haystack, boolean $strict = false)
Recursively searches an array $haystack for the value(s) $needle.
Assumes that all values in $needle (if $needle is an array) are at the SAME level, not spread across multiple dimensions of the $haystack.
at line 175
static array
array_map_recursive($f, $array)
Similar to array_map, but recurses when arrays are encountered.
Actually only one array argument is supported.
at line 195
static array
array_merge_recursive(array $array)
Recursively merges two or more arrays.
Behaves similar to array_merge_recursive(), however it only merges values when both are arrays rather than creating a new array with both values, as the PHP version does. The same behaviour also occurs with numeric keys, to match that of what PHP does to generate $_REQUEST.
at line 236
static array
flatten(array $array, boolean $preserveKeys = true, array $out = array())
Takes an multi dimension array and returns the flattened version.