Api‎ > ‎Util‎ > ‎

Util

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.

$regexstringThe full regular expression (including options such as "/.../ice").
$subjectmixedThe subject is a string or an array of strings that is subject to modification (passed in by reference).
$replaceboolThe optional replacement string (accepts variables such as "1").
$allboolWhether one or all instances should be matched/replaced (default: all=false).
$alwaysArrayboolBy 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.
returnsmixedThe 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.

$valuemixedThe value to be tested and returned if set.
$defaultmixedThe value to be returned if the first parameter is not set.
returnsmixed

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 *

$filestringFull path name of the file.
$contentsstringThe contents to be written.
$modestring"w" by default (write mode), optionally can be set to "a" (append mode).
Comments