|
RSI helpers
0.1
RSI helpers
|
String helpers. More...
Static Public Member Functions | |
| static | bool ($value) |
| Returns literally 'true' or 'false'. More... | |
| static | random ($length=32, $chars=null, $time=null) |
| Generate a random string. More... | |
| static | codeName ($index) |
| Generate a code-name, based on the index. More... | |
| static | nullify ($str) |
| Transform an empty string to a null. More... | |
| static | normalize ($str) |
| Remove accents from a string. More... | |
| static | urlify ($str, $replace='-') |
| Transform a string to a URL-friendly version. More... | |
| static | emojify ($str) |
| Replace ASCII emoji's by their Unicode equivalent. More... | |
| static | unleet ($str, $upper=false) |
| Remove leet-speak (1337 5p33k) from a string. More... | |
| static | icompare ($str1, $str2) |
| Case insesitive string comparison. More... | |
| static | pad ($str, $length, $pad='0', $type=STR_PAD_LEFT) |
| Pad function that defaults to left padding with zeros. More... | |
| static | format ($str, $format, $pad=null, $type=STR_PAD_LEFT, $replace=' *') |
| Format a string. More... | |
| static | camel ($str, $delimiters=' -_') |
| Converts a delimited string to CamelCase. More... | |
| static | snake ($str, $delimiter='_') |
| Converts a CamelCased string to snake_case. More... | |
| static | limit ($str, $length, $words=false, $delimiter='…') |
| Limit a string to a number of characters. More... | |
| static | parse ($str) |
| Parse a string into variables. More... | |
| static | strip (&$haystack, $needle) |
| Return part of a string until a needle. More... | |
| static | pop (&$haystack, $needle) |
| Return part of a string after a needle. More... | |
| static | part ($haystack, $needle, $index=0) |
| Return part of a string until a needle. More... | |
| static | insert ($str, $insert, $position, $length=0) |
| Insert a string at a certain position in another string. More... | |
| static | stripQuotes ($str, $quotes=["'",'"']) |
| Remove optinal quotes from a string. More... | |
| static | wrap ($str, $width) |
| Wrap a string into multiple lines (better wordwrap()). More... | |
| static | nl2p ($str) |
| Replace all newlines with HTML paragraph tags. More... | |
| static | nl2pbr ($str) |
| Replace all multi newlines with HTML paragraph tags, and single newlines with line breaks. More... | |
| static | transform ($str, $methods, &$count=null) |
| Transforms a string according to a certain function. More... | |
| static | startsWith ($haystack, $needle) |
| Check if a string starts with a specific value. More... | |
| static | startWith ($haystack, $needle) |
| Make sure a string starts with a specific value. More... | |
| static | endsWith ($haystack, $needle) |
| Check if a string ends with a specific value. More... | |
| static | endWith ($haystack, $needle) |
| Make sure a string ends with a specific value. More... | |
| static | numeric ($value) |
| Numeric detection. More... | |
| static | operator ($ref, $operator,$value, $default=false) |
| Evaluate an operator between a value and a reference value. More... | |
| static | implode ($array, $last_delimiter=null, $delimiter=', ') |
| Convert an array to a list. More... | |
| static | ranges ($array, $delimiter=', ', $separator=' - ') |
| Show ranges from a numerical array. More... | |
| static | replaceDate ($str, $time=null, $open='[', $close=']') |
| Replace date tags in a string. More... | |
| static | attributes ($str) |
| Extract attributes from a string. More... | |
Data Fields | |
| const | TRANSFORM_HTMLCHARS = 'htmlchars' |
| const | TRANSFORM_LCFIRST = 'lcfirst' |
| const | TRANSFORM_LOWER = 'lower' |
| const | TRANSFORM_NL2BR = 'nl2br' |
| const | TRANSFORM_NL2P = 'nl2p' |
| const | TRANSFORM_NL2PBR = 'nl2pbr' |
| const | TRANSFORM_TRIM = 'trim' |
| const | TRANSFORM_UCFIRST = 'ucfirst' |
| const | TRANSFORM_UCWORDS = 'ucwords' |
| const | TRANSFORM_UPPER = 'upper' |
| const | TRANSFORM_URLENCODE = 'urlencode' |
| const | TRANSFORM_URLIFY = 'urlify' |
| const | ATTRIBUTES_PATTERN = '\\s+(?<key>[\\w\\-]+)(?<value>=(\'([^\']*)\'|"([^"]*)"|(\\w+)))?' |
| const | PASSWORD_CHARS = 'abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789' |
| const | MAX_TIME = 20000000000 |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Format a string.
| string | $str | Base string (without formatting). |
| string | $format | Format, $replace characters are replaced with characters from the $str. |
| string | $pad | Optional padding (to number of $replace characters in $format). |
| int | $type | Padding type. |
| string | $replace | Characters to replace in the $format. |
|
static |
|
static |
|
static |
Insert a string at a certain position in another string.
| string | $str | String to insert to. |
| string | $insert | String to insert into $str. |
| int | $position | Position to insert at (negative = relative to end). |
| int | $length | Length of the part to replace with the insertion. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Evaluate an operator between a value and a reference value.
Besides the usual '==', '!=', '>', '>=', '<', '<=', en '' operators there are also some specific operators::
| string | $ref | Reference value. The value to look at. |
| string | $operator | Operator. |
| string | $value | Value sought after in the reference. |
| bool | $default | Default result (unknown operator). |
|
static |
|
static |
|
static |
|
static |
Return part of a string after a needle.
Shorten the string including the needle.
| string | $haystack | String to search in. |
| string | $needle | Needle to look for (not found = return string until end). |
|
static |
Generate a random string.
| int | $length | Length of the resulting string. |
| string | $chars | Characters to use. Ranges can be indicated as [{from}-{to}]. E.g. '[0-9][a-f]' for the hexadecimal range. Special cases: '*' all digits + letter (upper + lower case); '+': all digits + lower case letters; '@': all easy distinguishable characters (no 0/1/l/o). |
| int | bool | $time | Start the string with the time encoded in the available characters (makes them sequential). When true, the current time will be taken. |
|
static |
Show ranges from a numerical array.
For example [1,2,3,5,6,8,9,10] becomes '1 - 3, 5, 6, 8 - 10'.
| array | $array | Array with numbers. |
| string | $delimiter | Delimiter to use between ranges. |
| string | $separator | Seperator to use between boundaries of a range. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Remove leet-speak (1337 5p33k) from a string.
| string | $str | String with leet-speak characters. |
| bool | $upper | Replace with uppercase letters. |
|
static |
|
static |
| const ATTRIBUTES_PATTERN = '\\s+(?<key>[\\w\\-]+)(?<value>=(\'([^\']*)\'|"([^"]*)"|(\\w+)))?' |
| const PASSWORD_CHARS = 'abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789' |