Class DataStructureString
String Data Structure helper
Provides utility methods to assist in manipulating strings.
Methods summary
public
string
|
#
random( integer $length = 8, string $pool = null, array $options = [] )
Generates a random string from a list of characters
Generates a random string from a list of characters
Parameters
- $length
- The length of the random string
- $pool
The pool of characters to include in the random string,
defaults to alpha numeric characters. Can be configured further in $options['types']
- $options
An array of options including:
- types A numerically indexed-array of character-types that may be used to
generate the random string (i.e. "alpha", "alpha_lower", "alpha_upper", and/or "numeric") (optional)
Returns
string A randomly generated word with the given length
|
public
|
#
truncate( string $input, array $options = [] )
Truncates the string using the given options
Truncates the string using the given options
Parameters
- $input
- The input string to truncate
- $options
A list of options including any of the following:
- length The number of characters to truncate to - NOT multi-byte-safe (optional, default null)
- word_length The number of words to truncate to, broken at spaces (optional, default null)
- line_break True to truncate at the first new line, or false to allow new line breaks (optional, default true)
|
public
string
|
#
htmlToText( string $html )
Converts the HTML given to text
Converts the HTML given to text
Parameters
Returns
string The textual representation of the HTML
|
public
string
|
#
removeFromText( string $text, string|array $content )
Removes the given $content from the provided $text
Removes the given $content from the provided $text
Parameters
- $text
- The full text string
- $content
A string value, or numerically-indexed array of strings, representing exact
textual matches from which to remove from $text
Returns
string The provided $text with specific $content removed
|