Util
Util Class.
Static utility functions.
Tags
Table of Contents
extractFields() | Extracts specific fields from one associative array, and places them into another. | array |
---|---|---|
extractDigits() | Extracts numeric portion of a string (for example, for normalizing phone numbers). | string |
formatPhoneNumber() | Formats a phone number as a standard 7- or 10-digit string (xxx) xxx-xxxx. | string |
prettyPrintArray() | Nicely format an array for printing. | string |
randomPhrase() | Generate a random phrase, consisting of a specified number of adjectives, followed by a noun. | string |
Methods
extractFields()
Extracts specific fields from one associative array, and places them into another.
public
static extractFields(
&$inputArray :
array
, $fieldArray :
string[]
[, $remove :
bool
= true ]
)
: array
Parameters
- $inputArray : array
- $fieldArray : string[]
- $remove : bool = true
Return values
arrayextractDigits()
Extracts numeric portion of a string (for example, for normalizing phone numbers).
public
static extractDigits(
$str :
string
)
: string
Parameters
- $str : string
Return values
stringformatPhoneNumber()
Formats a phone number as a standard 7- or 10-digit string (xxx) xxx-xxxx.
public
static formatPhoneNumber(
$phone :
string
)
: string
Parameters
- $phone : string
Return values
stringprettyPrintArray()
Nicely format an array for printing.
public
static prettyPrintArray(
$arr :
array
)
: string
Parameters
- $arr : array
Return values
stringrandomPhrase()
Generate a random phrase, consisting of a specified number of adjectives, followed by a noun.
public
static randomPhrase(
$numAdjectives :
int
[, $maxLength :
int
= 9999999 ]
[, $maxTries :
int
= 10 ]
[, $separator :
string
= '-' ]
)
: string
Parameters
- $numAdjectives : int
- $maxLength : int = 9999999
- $maxTries : int = 10
- $separator : string = '-'