RSI helpers
0.1
RSI helpers
|
Record (array) helpers. More...
Static Public Member Functions | |
static | explode ($array, $delimiter=null, $separator=null) |
Enhanced explode. More... | |
static | implode ($array, $delimiter=null, $separator=null) |
Enhanced implode. More... | |
static | exists ($array, $key) |
Checks if a key exists in an array. More... | |
static | get ($array, $key, $default=null) |
Get a value from an array. More... | |
static | iget ($array, $key, $default=null) |
Get a value from an array in a case insensitive way. More... | |
static | set (&$array, $key, $value) |
Set a value of an array. More... | |
static | add (&$array, $key, $value=null) |
Add a value to an array if the key does not already exist. More... | |
static | delete (&$array, $key) |
Delete a (nested) key from an array. More... | |
static | flatten ($array, $key_glue=null, $key_prefix=null) |
Flattens a multi-dimensional array. More... | |
static | expand ($array, $key_glue) |
Brings a flattend array back to its multi-dimensional form. More... | |
static | value ($array, $index=0, $default=null) |
Get the n-th value from an array. More... | |
static | key ($array, $index=0) |
Get the n-th key from an array. More... | |
static | assoc ($array) |
Determine if an array is associative (that is, no ascending numerical key). More... | |
static | splice ($array, $offset, $length=0, $replace=null) |
Splice with keys. More... | |
static | merge (... $arrays) |
Merge arrays while preserving (duplicate) key sequence. More... | |
static | resize ($array, $length, $filler=null) |
Set the length of an array. More... | |
static | combine ($keys, $values, $filler=null) |
Creates an array by using one array for keys and another for its values. More... | |
static | isearch ($array, $value) |
Searches the array for a given value and returns the first corresponding key if successful. More... | |
static | prefix ($array, $prefix) |
Add a prefix to all members of an array. More... | |
static | prefixKey ($array, $prefix) |
Add a prefix to all keys of an array. More... | |
static | changeKey ($array, $keys, $keep=true) |
Change the keys of an array. More... | |
static | mergeKey ($array, $key_name=null, $value_name=null) |
Merge the key and value of an assoc.array into a record. More... | |
static | column ($array, $column) |
Return the values from a single column in the input array. More... | |
static | group ($array, $column) |
Group records by a column. More... | |
static | shuffle ($array) |
Shuffle an array. More... | |
static | average ($array) |
Calculate the average of an array. More... | |
static | deviation ($array, &$average=null) |
Calculate the mean average deviation of an array. More... | |
static | select ($array, $keys) |
Return specific keys from an array. More... | |
static | sort ($array, $options=null, $key=false) |
Sort an array. More... | |
static | ranges ($array) |
Retrieve numerical ranges from an array. More... | |
static | groupByLetter ($array, $length=1, $case_sensitive=false) |
Group a list of strings by its first letter(s). More... | |
static | groupByStart ($array, $max=25, $other=0, $min=true, $word='\\W+\\w *') |
Group a list of strings by its most common start. More... | |
Record (array) helpers.
Definition at line 8 of file Record.php.
|
static |
Add a value to an array if the key does not already exist.
array | $array | Array to store the value in. |
string | array | $key | Key to store the value at. An array indicates a nested key. If the array is ['foo' => ['bar' => 'acme']], then the nested key for the 'acme' value will be ['foo','bar']. |
mixed | $value |
Definition at line 126 of file Record.php.
|
static |
Determine if an array is associative (that is, no ascending numerical key).
array | $array |
Definition at line 195 of file Record.php.
|
static |
Calculate the average of an array.
array | $array | Array with numerical values. |
Definition at line 366 of file Record.php.
|
static |
Change the keys of an array.
array | $array | Source array. |
array | $keys | Key = old key, value = new key. |
bool | $keep | If true, entries in the source array for which there is nog new key defined, will be kept in the result (with their original key). |
Definition at line 296 of file Record.php.
|
static |
Return the values from a single column in the input array.
Basicly PHP's array_column, but then retaining key association.
array | $array | A multi-dimensional array (record set) from which to pull a column of values. |
string | $column | The column of values to return. |
Definition at line 329 of file Record.php.
|
static |
Creates an array by using one array for keys and another for its values.
Basicly PHP's array_combine, but then without the same length restriction.
array | $keys | Array of keys. |
array | $values | Array of values. |
mixed | $filler | Filler to use if array of values is shorter than keys. |
Definition at line 251 of file Record.php.
|
static |
Delete a (nested) key from an array.
array | $array | Array to delete the key from. |
string | array | $key | Key to delete. An array indicates a nested key. |
Definition at line 137 of file Record.php.
|
static |
Calculate the mean average deviation of an array.
array | $array | Array with numerical values. |
float | $average | Avarage value of array. |
Definition at line 375 of file Record.php.
|
static |
Checks if a key exists in an array.
array | $array | Array to look in. |
string | array | $key | Key to look at. An array indicates a nested key. If the array is ['foo' => ['bar' => 'acme']], then the nested key for the 'acme' value will be ['foo','bar']. |
Definition at line 53 of file Record.php.
|
static |
Brings a flattend array back to its multi-dimensional form.
array | $array | One dimensional array. |
string | $key_glue | Glue with which the keys are combined. |
Definition at line 166 of file Record.php.
|
static |
Enhanced explode.
mixed | $array | Value to turn into an array. |
string | $delimiter | Delimiter in case of a string. |
string | $separator | Key-value separator. |
Definition at line 17 of file Record.php.
|
static |
Flattens a multi-dimensional array.
array | $array | Array to flatten. |
string | $key_glue | Key to combine the keys with (sequential, numerical keys if empty). |
string | $key_prefix | Prefix for the key. |
Definition at line 153 of file Record.php.
|
static |
Get a value from an array.
array | $array | Array to look in. |
string | array | $key | Key to look at. An array indicates a nested key. If the array is ['foo' => ['bar' => 'acme']], then the nested key for the 'acme' value will be ['foo','bar']. |
mixed | $default | Default value if the key does not exist. |
Definition at line 70 of file Record.php.
|
static |
Group records by a column.
array | $array | A multi-dimensional array (record set). |
string | $column | The column to group by. |
Definition at line 340 of file Record.php.
|
static |
Group a list of strings by its first letter(s).
array | $array | Array with strings. |
int | $length | Number of characters to group by. |
bool | $case_sensitive | Use case sensitivity for grouping. |
Definition at line 439 of file Record.php.
|
static |
Group a list of strings by its most common start.
array | $array | Array with strings. |
int | $max | Maximum number of groups. |
int | bool | $other | Number of keys from the smallest groups to group into one single group (empty key) (true = half of average group size). |
int | bool | $min | Minimum group size (true = 10% of average group size). |
string | $word | Word mask (regex). |
Definition at line 459 of file Record.php.
|
static |
Get a value from an array in a case insensitive way.
array | $array | Array to look in. |
string | array | $key | Key to look at (case insensitive). An array indicates a nested key. If the array is ['foo' => ['bar' => 'acme']], then the nested key for the 'acme' value will be ['foo','bar']. |
mixed | $default | Default value if the key does not exist. |
Definition at line 85 of file Record.php.
|
static |
Enhanced implode.
mixed | $array | Array to turn into a string |
string | $delimiter | Delimiter. |
string | $separator | Key-value separator. |
Definition at line 40 of file Record.php.
|
static |
Searches the array for a given value and returns the first corresponding key if successful.
Basicly PHP's array_search, but case insensitive.
array | $array | Array with values. |
mixed | $value | Value to look for. |
Definition at line 261 of file Record.php.
|
static |
Get the n-th key from an array.
array | $array | Array to get key from. |
int | $index | Key index (negative = start from end). |
Definition at line 187 of file Record.php.
|
static |
Merge arrays while preserving (duplicate) key sequence.
E.g. ['a' => 5,'b' => 7,'d' => 3] + ['b' => 4,'c' => 2,'d' => 1] returns ['a' => 5,'b' => 4,'c' => 2,'d' => 1].
array | $arrays,... | input array(s). |
Definition at line 216 of file Record.php.
|
static |
Merge the key and value of an assoc.array into a record.
array | $array | Assoc.array. |
string | $key_name | Name under which the key is added to the record. If empty the key is not added. |
string | $value_name | Name under which the value is added to the record. If empty, and the value is an array, this array is merged with the record. Otherwise the value is not added. |
Definition at line 311 of file Record.php.
|
static |
Add a prefix to all members of an array.
array | $array | Array with values. |
string | $prefix | Prefix to add. |
Definition at line 273 of file Record.php.
|
static |
Add a prefix to all keys of an array.
array | $array | Array with values. |
string | $prefix | Prefix to add. |
Definition at line 284 of file Record.php.
|
static |
Retrieve numerical ranges from an array.
array | $array | Array with numbers. |
Definition at line 415 of file Record.php.
|
static |
Set the length of an array.
array | $array | Input array. |
int | $length | Desired length. |
mixed | $filler | Value for new possible entries. |
Definition at line 240 of file Record.php.
|
static |
Return specific keys from an array.
array | $array | Array to select from. |
array | $keys | Keys to select. |
Definition at line 387 of file Record.php.
|
static |
Set a value of an array.
If the key does not exist it will be created. With a nested key, sub-array will also be created.
array | $array | Array to store the value in. |
string | array | $key | Key to store the value at. An array indicates a nested key. If the array is ['foo' => ['bar' => 'acme']], then the nested key for the 'acme' value will be ['foo','bar']. |
mixed | $value |
Definition at line 110 of file Record.php.
|
static |
Shuffle an array.
Basicly PHP's shuffle, but then retaining key association (and not altering the input array).
array | $array | Input array. |
Definition at line 354 of file Record.php.
|
static |
Sort an array.
array | $array | Array to sort. |
callable | int | $options | Callback function for sorting or sorting flags. |
bool | $key | Sort by key. |
Definition at line 399 of file Record.php.
|
static |
Splice with keys.
array | $array | Input array. |
int | $offset | Where to start (negative = from end). |
int | $length | Length of part to remove. |
array | $replace | Array to replace removed part with. |
Definition at line 206 of file Record.php.
|
static |
Get the n-th value from an array.
array | $array | Array to get value from. |
int | $index | Value index (negative = start from end). |
mixed | $default | Default value if the index does not exist. |
Definition at line 178 of file Record.php.