Methods summary
public static
boolean
|
#
checkEncoding( string $s )
Checks if the string is valid for UTF-8 encoding.
Checks if the string is valid for UTF-8 encoding.
Parameters
Returns
boolean bool
|
public static
string
|
#
fixEncoding( string $s )
Removes invalid code unit sequences from UTF-8 string.
Removes invalid code unit sequences from UTF-8 string.
Parameters
Returns
string string
|
public static
string
|
#
chr( integer $code )
Returns a specific character in UTF-8.
Returns a specific character in UTF-8.
Parameters
- $code
- point (0x0 to 0xD7FF or 0xE000 to 0x10FFFF)
Returns
string string
Throws
|
public static
boolean
|
#
startsWith( string $haystack, string $needle )
Starts the $haystack string with the prefix $needle?
Starts the $haystack string with the prefix $needle?
Parameters
Returns
boolean bool
|
public static
boolean
|
#
endsWith( string $haystack, string $needle )
Ends the $haystack string with the suffix $needle?
Ends the $haystack string with the suffix $needle?
Parameters
Returns
boolean bool
|
public static
boolean
|
#
contains( string $haystack, string $needle )
Does $haystack contain $needle?
Does $haystack contain $needle?
Parameters
Returns
boolean bool
|
public static
string
|
#
substring( string $s, integer $start, integer $length = null )
Returns a part of UTF-8 string.
Returns a part of UTF-8 string.
Parameters
- $s
- $start
- characters (code points)
- $length
- characters (code points)
Returns
string string
|
public static
string
|
#
normalize( string $s )
Removes special controls characters and normalizes line endings and
spaces.
Removes special controls characters and normalizes line endings and
spaces.
Parameters
Returns
string string
|
public static
string
|
#
normalizeNewLines( string $s )
Standardize line endings to unix-like.
Standardize line endings to unix-like.
Parameters
Returns
string string
|
public static
string
|
#
toAscii( string $s )
Converts to ASCII.
Parameters
Returns
string ASCII
|
public static
string
|
#
webalize( string $s, string $charlist = null, boolean $lower = true )
Converts to web safe characters [a-z0-9-] text.
Converts to web safe characters [a-z0-9-] text.
Parameters
- $s
- encoding
- $charlist
- characters
- $lower
Returns
string string
|
public static
string
|
#
truncate( string $s, integer $maxLen, string $append = "\xE2\x80\xA6" )
Truncates string to maximal length.
Truncates string to maximal length.
Parameters
- $s
- encoding
- $maxLen
- $append
- encoding
Returns
string string
|
public static
string
|
#
indent( string $s, integer $level = 1, string $chars = "\t" )
Indents the content from the left.
Indents the content from the left.
Parameters
- $s
- encoding or 8-bit
- $level
- $chars
Returns
string string
|
public static
string
|
#
lower( string $s )
Convert to lower case.
Parameters
Returns
string string
|
public static
string
|
#
firstLower( string $s )
Convert first character to lower case.
Convert first character to lower case.
Parameters
Returns
string string
|
public static
string
|
#
upper( string $s )
Convert to upper case.
Parameters
Returns
string string
|
public static
string
|
#
firstUpper( string $s )
Convert first character to upper case.
Convert first character to upper case.
Parameters
Returns
string string
|
public static
string
|
#
capitalize( string $s )
Capitalize string.
Parameters
Returns
string string
|
public static
boolean
|
#
compare( string $left, string $right, integer $len = null )
Case-insensitive compares UTF-8 strings.
Case-insensitive compares UTF-8 strings.
Parameters
Returns
boolean bool
|
public static
string
|
#
findPrefix( ... $strings )
Finds the length of common prefix of strings.
Finds the length of common prefix of strings.
Parameters
Returns
string string
|
public static
integer
|
#
length( string $s )
Returns number of characters (not bytes) in UTF-8 string. That is the number
of Unicode code points which may differ from the number of graphemes.
Returns number of characters (not bytes) in UTF-8 string. That is the number
of Unicode code points which may differ from the number of graphemes.
Parameters
Returns
integer int
|
public static
string
|
|
public static
string
|
#
padLeft( string $s, integer $length, string $pad = ' ' )
Pad a string to a certain length with another string.
Pad a string to a certain length with another string.
Parameters
Returns
string string
|
public static
string
|
#
padRight( string $s, integer $length, string $pad = ' ' )
Pad a string to a certain length with another string.
Pad a string to a certain length with another string.
Parameters
Returns
string string
|
public static
string
|
#
reverse( string $s )
Reverse string.
Parameters
Returns
string string
|
public static
string|false
|
#
before( string $haystack, string $needle, integer $nth = 1 )
Returns part of $haystack before $nth occurence of $needle.
Returns part of $haystack before $nth occurence of $needle.
Parameters
- $haystack
- $needle
- $nth
- value means searching from the end
Returns
string|false returns false if the needle was not found
|
public static
string|false
|
#
after( string $haystack, string $needle, integer $nth = 1 )
Returns part of $haystack after $nth occurence of $needle.
Returns part of $haystack after $nth occurence of $needle.
Parameters
- $haystack
- $needle
- $nth
- value means searching from the end
Returns
string|false returns false if the needle was not found
|
public static
integer|false
|
#
indexOf( string $haystack, string $needle, integer $nth = 1 )
Returns position of $nth occurence of $needle in $haystack.
Returns position of $nth occurence of $needle in $haystack.
Parameters
- $haystack
- $needle
- $nth
- value means searching from the end
Returns
integer|false offset in characters or false if the needle was not found
|
public static
array
|
#
split( string $subject, string $pattern, integer $flags = 0 )
Splits string by a regular expression.
Splits string by a regular expression.
Parameters
Returns
array array
|
public static
mixed
|
#
match( string $subject, string $pattern, integer $flags = 0, integer $offset = 0 )
Performs a regular expression match.
Performs a regular expression match.
Parameters
- $subject
- $pattern
- $flags
- be PREG_OFFSET_CAPTURE (returned in bytes)
- $offset
- in bytes
Returns
mixed mixed
|
public static
array
|
#
matchAll( string $subject, string $pattern, integer $flags = 0, integer $offset = 0 )
Performs a global regular expression match.
Performs a global regular expression match.
Parameters
- $subject
- $pattern
- $flags
- be PREG_OFFSET_CAPTURE (returned in bytes); PREG_SET_ORDER is default
- $offset
- in bytes
Returns
array array
|
public static
string
|
#
replace( string $subject, string|array $pattern, string|callable $replacement = null, integer $limit = -1 )
Perform a regular expression search and replace.
Perform a regular expression search and replace.
Parameters
- $subject
- $pattern
- $replacement
- $limit
Returns
string string
|
public static
|
|