insert_unique()
insert_unique(array $arr, mixed $val) : array
A functon to test if an array element exists and if it does not, add the value specified.
Parameters
| array | $arr | The input array |
| mixed | $val |
Utility methods to deal with arrays.
key_exists_substr(array $arr, string $expr) : boolean
A method to test if an array element exists by testing a subset of it's key.
| array | $arr | The array to test |
| string | $expr | The substring expression to test for |
| None found |
find_key_regexp(array $arr, string $expr) : mixed
Test if an array key exists, given a regular expression.
| array | $arr | The array to search |
| string | $expr | The regular expression to use in the search |
FALSE or actual key name.
| None found |
merge_by_keys(array $arr1, array $arr2, string $key1 = 'name', string $key2 = 'name')
Merge two arrays of hashes based on certain keys
| array | $arr1 | The primary array |
| array | $arr2 | The array to be merged |
| string | $key1 | The key field in the first array |
| string | $key2 | The key field in the second array |
| None found |
to_hash(array $input, string $key) : array
re-arrange an array of arrays into a hash of arrays by a specified key.
| array | $input | The input array |
| string | $key | The key to create the output array on |
| None found |
extract_field(array $input, string $key) : array
Extract one field from an array of hashes into a flat array
| array | $input | The input associative array |
| string | $key | The key to extract from the array of hashes |
| None found |
compare_elements_by_sortorder_key(array $e1, array $e2, string $key = 'sort_key') : integer
Compare two hashes by the key 'sort_key' This function is useful for sorting arrays of hashes.
| array | $e1 | Associative Array 1 |
| array | $e2 | Associative Array 2 |
| string | $key | The key to sort each element by |
-1, 0, or -1
| None found |
hashsort(array $input, string $key, boolean $is_string = false, boolean $casecompare = false) : boolean
Sort array of hashes by key
| array | $input | An array of hashes. This array of hashes is sorted. |
| string | $key | The hash key to sort by |
| boolean | $is_string | A boolean indicating if the key is a string |
| boolean | $casecompare | If $is_string is true, wether or not to do case sensitive comparisons |
| None found |
objsort(array $input, string $member, boolean $is_string = false, boolean $casecompare = false) : boolean
Sort array of objects by member
| array | $input | Arreay of objects to sort |
| string | $member | The member name to sort on |
| boolean | $is_string | Indicates wether the member is a string |
| boolean | $casecompare | Wether the values should be sorted in a case sensitive, or case insensitive manner. |
| None found |
hashrsort(array $input, string $key, boolean $is_string = false, boolean $casecompare = false) : void
Sort array of hashes by key in reverse order
| array | $input | The input array of hashes. This array is modified on output |
| string | $key | The hash key to sort by |
| boolean | $is_string | Wether the value of the key is a string or not |
| boolean | $casecompare | If the value of the key is a string, wether it should be sorted in a case sensitive manner, or not. |
| None found |
explode_with_key(string $str, string $inglue = '=', string $outglue = '&') : array
Explode an array into a hash useful for separating params on a URL into a hash
| string | $str | The input string. |
| string | $inglue | inner glue string (separates name from value) |
| string | $outglue | outer glue string (separates each variable/value combination) |
| None found |
find_index(array $data, mixed $needle) : \index
Given an array and a value, return the index of that value
| array | $data | |
| mixed | $needle |
or FALSE
| None found |
implode_with_key(\hash $assoc, string $inglue = '=', string $outglue = '&')
Implode a hash into an array suitable for forming a URL string with multiple key/value pairs
| \hash | $assoc | input hash |
| string | $inglue | inner glue |
| string | $outglue | outer glue |
| returns |
string; |
|---|
implode_quoted(array $data, string $glue = ',', string $quote = '"') : string
Given an array, implode it into a string with non empty values quoted.
| array | $data | The input array |
| string | $glue | How each value should be separated in the input |
| string | $quote | How non empty fields should be deliminated |
| None found |
str_putcsv(array $input, \string $delimiter = ',', \string $enclosure = '"')
| array | $input | |
| \string | $delimiter | |
| \string | $enclosure |
| None found |
to_object(\hash $array, boolean $recursive = FALSE) : \stdclass
Convert a hash into a stdclass object
| \hash | $array | input array |
| boolean | $recursive | Wether or not to do recursive conversion |
object.
| None found |
hash_prepend(\hash $input, string $key, mixed $value) : \hash
Prepend a key/value pair to a hash.
This is useful when prepending an 'any' value to a list retrieved from the database, for use in filtering dialogs etc.
| \hash | $input | input array |
| string | $key | The key to prepend |
| mixed | $value | The value to prepend |
| None found |
remove_by_value(array $input, string $value = '') : array
Remove All elements of the input array that have the specified value
| array | $input | The input hash/array |
| string | $value | The value to remove |
| None found |
is_hash(array $arr) : boolean
Test if the input array is an associative array (strings or something else for keys, instead of linearly increasing integers)
| array | $arr | The test array |
| None found |
explode_to_tree(array $hash, string $delimiter = '.', string $baseval = false)
Given a hash of records, where the key denotes the path separeted with a delimieter, generate a tree of records.
| array | $hash | The input hash |
| string | $delimiter | The identifier delimiter (used on hash keys) |
| string | $baseval | Internal use only |
| None found |
smart_explode(string $str, string $delim = ',', string $safe_char = '"') : array
Smartly explode a string into an array given a delimiter, and a safe character.
Any instances of the delimiter inside two 'safe characters' will be included in the value.
This is useful when importing data from CSV.
| string | $str | The input string |
| string | $delim | The field delimeter |
| string | $safe_char | The save character |
| None found |
search_recursive(array $input, string $needle) : mixed
Search a hash (recursively) to find an entry where the key specified is found
| array | $input | A (potentially recursive) hash |
| string | $needle | a member name |
The value of the found member
| None found |