Strings
class Strings
String tools library.
Constants
TRIM_CHARACTERS |
|
Methods
Checks if the string is valid for UTF-8 encoding.
Removes invalid code unit sequences from UTF-8 string.
Returns a specific character in UTF-8.
Starts the $haystack string with the prefix $needle?
Ends the $haystack string with the suffix $needle?
Does $haystack contain $needle?
Returns a part of UTF-8 string.
Removes special controls characters and normalizes line endings and spaces.
Standardize line endings to unix-like.
Converts to ASCII.
Converts to web safe characters [a-z0-9-] text.
Truncates string to maximal length.
Indents the content from the left.
Convert to lower case.
Convert first character to lower case.
Convert to upper case.
Convert first character to upper case.
Capitalize string.
Case-insensitive compares UTF-8 strings.
Finds the length of common prefix of strings.
Returns number of characters (not bytes) in UTF-8 string.
Strips whitespace.
Pad a string to a certain length with another string.
Pad a string to a certain length with another string.
Reverse string.
Returns part of $haystack before $nth occurence of $needle.
Returns part of $haystack after $nth occurence of $needle.
Returns position of $nth occurence of $needle in $haystack.
Splits string by a regular expression.
Performs a regular expression match.
Performs a global regular expression match.
Perform a regular expression search and replace.
No description
Details
at line 28
static bool
checkEncoding($s)
Checks if the string is valid for UTF-8 encoding.
at line 39
static string
fixEncoding($s)
Removes invalid code unit sequences from UTF-8 string.
at line 52
static string
chr($code)
Returns a specific character in UTF-8.
at line 67
static bool
startsWith($haystack, $needle)
Starts the $haystack string with the prefix $needle?
at line 79
static bool
endsWith($haystack, $needle)
Ends the $haystack string with the suffix $needle?
at line 91
static bool
contains($haystack, $needle)
Does $haystack contain $needle?
at line 104
static string
substring($s, $start, $length = null)
Returns a part of UTF-8 string.
at line 122
static string
normalize($s)
Removes special controls characters and normalizes line endings and spaces.
at line 144
static string
normalizeNewLines($s)
Standardize line endings to unix-like.
at line 155
static string
toAscii($s)
Converts to ASCII.
at line 199
static string
webalize($s, $charlist = null, $lower = true)
Converts to web safe characters [a-z0-9-] text.
at line 218
static string
truncate($s, $maxLen, $append = "…")
Truncates string to maximal length.
at line 243
static string
indent($s, $level = 1, $chars = "\t")
Indents the content from the left.
at line 257
static string
lower($s)
Convert to lower case.
at line 268
static string
firstLower($s)
Convert first character to lower case.
at line 279
static string
upper($s)
Convert to upper case.
at line 290
static string
firstUpper($s)
Convert first character to upper case.
at line 301
static string
capitalize($s)
Capitalize string.
at line 314
static bool
compare($left, $right, $len = null)
Case-insensitive compares UTF-8 strings.
at line 332
static string
findPrefix(...$strings)
Finds the length of common prefix of strings.
at line 358
static int
length($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.
at line 370
static string
trim($s, $charlist = self::TRIM_CHARACTERS)
Strips whitespace.
at line 384
static string
padLeft($s, $length, $pad = ' ')
Pad a string to a certain length with another string.
at line 399
static string
padRight($s, $length, $pad = ' ')
Pad a string to a certain length with another string.
at line 412
static string
reverse($s)
Reverse string.
at line 422
static
random($length = 10, $charlist = '0-9a-z')
deprecated
deprecated
Use Nette\Utils\Random::generate
at line 436
static string|false
before($haystack, $needle, $nth = 1)
Returns part of $haystack before $nth occurence of $needle.
at line 452
static string|false
after($haystack, $needle, $nth = 1)
Returns part of $haystack after $nth occurence of $needle.
at line 468
static int|false
indexOf($haystack, $needle, $nth = 1)
Returns position of $nth occurence of $needle in $haystack.
at line 514
static array
split($subject, $pattern, $flags = 0)
Splits string by a regular expression.
at line 528
static mixed
match($subject, $pattern, $flags = 0, $offset = 0)
Performs a regular expression match.
at line 547
static array
matchAll($subject, $pattern, $flags = 0, $offset = 0)
Performs a global regular expression match.
at line 569
static string
replace($subject, $pattern, $replacement = null, $limit = -1)
Perform a regular expression search and replace.
at line 592
static
pcre($func, $args)
internal |
No description
Traits
Static class.