Class RUtil
You will get used to these static utility functions that didn't make it into php such as: writeFile, preg, nvl, min, max.
Vars
Functions
static mixed function preg($regex, $subject, $replace, $all, $alwaysArray)
Returns the matches of a perl regular expression in an array (getting rid of the unnecessary first element that preg_match generates) ; the result is returned in a scalar if one variable is matched (\1) and alternatively in array. The matches can also be replaced.
$regex | string | The full regular expression (including options such as "/.../ice"). |
$subject | mixed | The subject is a string or an array of strings that is subject to modification (passed in by reference). |
$replace | bool | The optional replacement string (accepts variables such as "1"). |
$all | bool | Whether one or all instances should be matched/replaced (default: all=false). |
$alwaysArray | bool | By default when only one variable is matched, it is returned as a scalar (e.g. by default"/ (a) /" is returned as scalar, "/ (a) (b) /" as an array). Setting this to true will always return the matches as an array. |
returns | mixed | The match or matches. This can be a string, an array of strings or an array of an array of strings (match all). Null when no matches. |
static mixed function nvl($value, $default)
Just like the Oracle NVL: Returns the first parameter if set. Returns the default value if the first parameter is NULL or empty string.
$value | mixed | The value to be tested and returned if set. |
$default | mixed | The value to be returned if the first parameter is not set. |
returns | mixed | |
static void function min()
*
Returns the minimum value of a list of numeric prameters. Null values are ignored.
* $value number* Multiple numbers of which the minimum should be determined. Alternatively the numbers can be passed in as an array as well.
$result number Lowest value or null for no parameters.
static void function max()
*
Returns the minimum value of an set of numeric parameters. Null values are ignored.
* $value number* Multiple numbers of which the maximum should be determined. Alternatively the numbers can be passed in as an array as well.
$result number Highest value or null for no parameters.
static void function sum()
*
Returns the minimum value of a list of numeric prameters. Null values are ignored.
* $value number* Multiple numbers of which the minimum should be determined. Alternatively the numbers can be passed in as an array as well.
$result number Lowest value or null for no parameters.
static void function writeFile($file, $contents, $mode)
*
Write the contents to a file
*
$file | string | Full path name of the file. |
$contents | string | The contents to be written. |
$mode | string | "w" by default (write mode), optionally can be set to "a" (append mode). |
|