Go to the source code of this file.
Functions | |
| is_numeric_array ($arr, $check_all=false) | |
| Test if the supplied argument is a numeric array (list). | |
| is_assoc_array ($arr, $check_all=false) | |
| Test if the supplied argument is an associative array (dictionary, hash). | |
| array_get_default (&$arr, $key, $default=null, $set_if_not_present=false) | |
| Returns the value in an array specified by a given key or the default value if the key does not exist. | |
| array_set_default (&$arr, $key, $default=null) | |
| Returns the value in an array specified by a given key or the default value if the key does not exist. | |
| array_get_int ($arr, $key, $default=null) | |
| Returns an integer value from an array specified by a given key or the default value if the key does not exist. | |
| array_get_bool ($arr, $key, $default=null) | |
| Returns a boolean value from an array specified by a given key or the default value if the key does not exist. | |
| array_unset_key (&$arr, $key) | |
| Removes a key from an array. | |
| array_unset_keys (&$arr, $keys) | |
| Unsets all items in $arr that have an index that is present in $keys. | |
| array_remove_keys (&$arr, $keys) | |
| Alias for the array_unset_keys() function. | |
| array_format ($arr, $align_left=true) | |
| Formats a one-dimensional associative array into an human-readable multiline string. | |
| array_has_key ($arr, $key) | |
| Checks if an array has a given key. | |
| array_has_value ($arr, $key, $strict=false) | |
| Checks if an array has a given value. | |
| array_clear (&$arr) | |
| Removes all items from the array. | |
| array_flip_string_keys ($arr) | |
| Exchanges all string keys with their associated values. | |
| array_check_types ($arr, $typespec, $cast=true) | |
| Checks the types of all elements in an array against a given type specification. | |
| require_args (&$arr, $typespec) | |
| Convenience wrapper for array_check_types that throws an error if the array didn't match the given type specification. | |
| implode_newlines ($arr) | |
| Joins all elements of an array containing strings into one single string, using new line characters as glue. | |
| implode_spaces ($arr) | |
| Joins all elements of an array containing strings into one single string, using space characters as glue. | |
| implode_empty ($arr) | |
| Joins all elements of an array containing strings into one single string, using the empty string as glue. | |
| array_trim_strings ($arr, $charlist=null) | |
| Trims all values of an array with strings. | |
| _array_trim_strings_cb (&$value, $key=null, $charlist=null) | |
| Callback function to apply trim() in-place to the specified value. | |
| numeric_array_to_associative_array ($arr) | |
| Transforms a numeric array into an associative array pair-wise. | |
| natksort (&$arr) | |
| Sort array keys using natural order. | |
Definition in file array.lib.php.
| is_numeric_array | ( | $ | arr, | |
| $ | check_all = false | |||
| ) |
Test if the supplied argument is a numeric array (list).
For performance reasons, this function only checks the first element of the array by default.
| $arr | The array to test | |
| $check_all | Whether to check all elements instead of just the first (optional, defaults to false) |
Definition at line 33 of file array.lib.php.
| is_assoc_array | ( | $ | arr, | |
| $ | check_all = false | |||
| ) |
Test if the supplied argument is an associative array (dictionary, hash).
For performance reasons, this function only checks the first element of the array by default.
| $arr | The array to test | |
| $check_all | Whether to check all elements instead of just the first (optional, defaults to false) |
Definition at line 71 of file array.lib.php.
| array_get_default | ( | &$ | arr, | |
| $ | key, | |||
| $ | default = null, |
|||
| $ | set_if_not_present = false | |||
| ) |
Returns the value in an array specified by a given key or the default value if the key does not exist.
This function lets you use a default value for array items that do not exist. This is especially useful if you use a configuration array in which not all keys are filled in.
| $arr | The array containing the data. | |
| $key | The key, given as int or string. | |
| $default | The default return value if no value was found. | |
| $set_if_not_present | Internal parameter, used by array_set_default (optional, do not use directly) |
array_get_string
Definition at line 110 of file array.lib.php.
| array_set_default | ( | &$ | arr, | |
| $ | key, | |||
| $ | default = null | |||
| ) |
Returns the value in an array specified by a given key or the default value if the key does not exist.
Additionally, it changes the array by storing the default if the key didn't exist. Note that this function alters the specified $arr parameter.
| $arr | The array containing the data. | |
| $key | The key, given as int or string. | |
| $default | The default return value if no value was found. |
Definition at line 146 of file array.lib.php.
| array_get_int | ( | $ | arr, | |
| $ | key, | |||
| $ | default = null | |||
| ) |
Returns an integer value from an array specified by a given key or the default value if the key does not exist.
If the value is a string, it will be validated and converted to an integer.
| $arr | The array containing the data. | |
| $key | The key, given as int or string. | |
| $default | The default return value if no value was found. |
Definition at line 172 of file array.lib.php.
| array_get_bool | ( | $ | arr, | |
| $ | key, | |||
| $ | default = null | |||
| ) |
Returns a boolean value from an array specified by a given key or the default value if the key does not exist.
If the value is a string, it will be validated and converted to a boolean. Recognized strings: 1, 0, true, false, yes, no, on, off.
| $arr | The array containing the data. | |
| $key | The key, given as int or string. | |
| $default | The default return value if no value was found. |
Definition at line 209 of file array.lib.php.
| array_unset_key | ( | &$ | arr, | |
| $ | key | |||
| ) |
Removes a key from an array.
The specified array is altered in-place.
| $arr | The array containing the data. | |
| $key | The key to unset. |
Definition at line 236 of file array.lib.php.
| array_unset_keys | ( | &$ | arr, | |
| $ | keys | |||
| ) |
Unsets all items in $arr that have an index that is present in $keys.
This function does not have a return value: the specified array is altered in-place.
| $arr | The array containing the data (original) | |
| $keys | A numeric array containing all key names to be unset. |
Definition at line 256 of file array.lib.php.
| array_remove_keys | ( | &$ | arr, | |
| $ | keys | |||
| ) |
Alias for the array_unset_keys() function.
| $arr | The array containing the data (original) | |
| $keys | A numeric array containing all key names to be unset. |
Definition at line 280 of file array.lib.php.
| array_format | ( | $ | arr, | |
| $ | align_left = true | |||
| ) |
Formats a one-dimensional associative array into an human-readable multiline string.
The result can be used for storage in a text file, database record or email message. The format was inspired by the output of the \G command on a mysql command prompt.
| $arr | The array to be formatted. | |
| $align_left | An optional parameter specifying if the key names should be left-aligned or right-aligned. The default is to use left-aligned key names.. |
Definition at line 302 of file array.lib.php.
| array_has_key | ( | $ | arr, | |
| $ | key | |||
| ) |
Checks if an array has a given key.
This function does the same as array_key_exists, but the arguments are swapped.
| $arr | An array | |
| $key | The key name to check for |
Definition at line 384 of file array.lib.php.
| array_has_value | ( | $ | arr, | |
| $ | key, | |||
| $ | strict = false | |||
| ) |
Checks if an array has a given value.
This function does the same as in_array, but the arguments are swapped.
| $arr | An array | |
| $key | The key name to check for | |
| $strict | Boolean indicating whether type-checking should be done |
Definition at line 406 of file array.lib.php.
| array_clear | ( | &$ | arr | ) |
Removes all items from the array.
The passed array is modified in-place. If you just want an empty array, use array() instead;
| $arr | The array to clear |
Definition at line 419 of file array.lib.php.
| array_flip_string_keys | ( | $ | arr | ) |
Exchanges all string keys with their associated values.
This function does basically the same as array_flip(), but this function does not flip key/value pairs with an integer key, while array_flip() does. This function returns a modified copy of your array; the original array is left untouched.
| $arr | The array containing the data |
Definition at line 437 of file array.lib.php.
| array_check_types | ( | $ | arr, | |
| $ | typespec, | |||
| $ | cast = true | |||
| ) |
Checks the types of all elements in an array against a given type specification.
This method can be used to easily validate the types of data in an array.
| $arr | The array containing the data. Example: (1, "foo", true) | |
| $typespec | A string with letters denoting variable types. These letters are supported: a: array, b: boolean, f: float, i: integer, o: object and s: string. Example: "isb". | |
| $cast | If this parameter is true, strings that look like integers are casted to real integers. Note that the original array will be modified in-place. |
Definition at line 473 of file array.lib.php.
| require_args | ( | &$ | arr, | |
| $ | typespec | |||
| ) |
Convenience wrapper for array_check_types that throws an error if the array didn't match the given type specification.
Refer to the array_check_types documentation for more information.
| $arr | The array to check. | |
| $typespec | A type specification. |
Definition at line 550 of file array.lib.php.
| implode_newlines | ( | $ | arr | ) |
Joins all elements of an array containing strings into one single string, using new line characters as glue.
| $arr | The array to join together. |
Definition at line 567 of file array.lib.php.
| implode_spaces | ( | $ | arr | ) |
Joins all elements of an array containing strings into one single string, using space characters as glue.
| $arr | The array to join together. |
Definition at line 584 of file array.lib.php.
| implode_empty | ( | $ | arr | ) |
Joins all elements of an array containing strings into one single string, using the empty string as glue.
| $arr | The array to join together. |
Definition at line 601 of file array.lib.php.
| array_trim_strings | ( | $ | arr, | |
| $ | charlist = null | |||
| ) |
Trims all values of an array with strings.
This function calls trim() on each value in the array. This function operates on a copy of the array; the original array is left untouched.
| $arr | The array containing strings to be trimmed. | |
| $charlist | Optional list of characters to be trimmed (passed on unmodified to the trim() function |
Definition at line 623 of file array.lib.php.
| _array_trim_strings_cb | ( | &$ | value, | |
| $ | key = null, |
|||
| $ | charlist = null | |||
| ) | [private] |
Callback function to apply trim() in-place to the specified value.
| &$value | The string to be trimmed. | |
| $key | Required by array_walk, not of any use here | |
| $charlist | The characters to be trimmed. Passed on to trim() |
Definition at line 652 of file array.lib.php.
| numeric_array_to_associative_array | ( | $ | arr | ) |
Transforms a numeric array into an associative array pair-wise.
The numeric array is assumed to be a (key, value, key, value, ...) list. All keys must be strings or integers, values can be anything. Make sure you provide an even number of values in the input; if not, the last value will be silently ignored.
| $arr | Multiple values or a single array to be converted |
Definition at line 676 of file array.lib.php.
| natksort | ( | &$ | arr | ) |
Sort array keys using natural order.
The passed array is modified in-place. This function orders an array the 'natural' way, based on key values. Keys as a1, a10, a2 will sort as a1, a2, a10.
| $arr | Reference to array to be natsorted |
Definition at line 705 of file array.lib.php.
1.5.9