- class
str
(php\lib\str
) - package
std
- source
php/lib/Str.php
Description
Class str
str ::
pos()
- Returns the index within this string of the first occurrence of thestr ::
posIgnoreCase()
- The same method as pos() only with ignoring case charactersstr ::
lastPos()
- Returns the index within this string of the last occurrence of thestr ::
lastPosIgnoreCase()
- The same method aslastPos()
only with ignoring case charactersstr ::
sub()
- Returns a new string that is a substring of this string. Thestr ::
compare()
- Compares two strings lexicographically.str ::
compareIgnoreCase()
- The same method ascompare()
only with ignoring case charactersstr ::
equalsIgnoreCase()
- Checks that the strings are equal with ignoring case charactersstr ::
startsWith()
- Tests if the substring of this string beginning at thestr ::
endsWith()
- Tests if this string ends with the specified suffix.str ::
lower()
- Converts all of the characters in$string
to lowerstr ::
upper()
- Converts all of the characters in$string
to upperstr ::
length()
- Returns the length of$string
.str ::
replace()
- Replaces each substring of this string that matches the literal targetstr ::
repeat()
- Return s a new string consisting of the original$string
repeatedstr ::
trim()
- Returns a copy of the string, with leading and trailing whitespacestr ::
trimRight()
str ::
trimLeft()
str ::
reverse()
- Reverse the string.str ::
shuffle()
- Returns a randomized string based on chars in $stringstr ::
random()
- Returns a new random string based on set.str ::
split()
- The method like explode() in Zend PHP.str ::
join()
- The method likeimplode()
in Zend PHP.str ::
encode()
- Converts $string by using $charset and returns a binary string.str ::
decode()
- Decodes $string by using $charset to UNICODE, returns a unicode string.str ::
isNumber()
- Returns true if $string is integer number (e.g: '12893', '3784', '0047')str ::
isLower()
str ::
isUpper()
str ::
lowerFirst()
str ::
upperFirst()
str ::
parseAs()
- Parse text as json, ini, yaml, etc.str ::
formatAs()
- Format value as ini, json, yml, etc.str ::
format()
str ::
contains()
- Returns true if string contains a substring.str ::
count()
- Возвращает количество найденный строк в другой строке.str ::
uuid()
str ::
hash()
- Возвращает хеш строки.str ::
lines()
- Переводит многострочный текст в массив, если $removeEmpty true, то удаляет пустые строки из результата.
str::pos(string $string, string $search, int $fromIndex): int
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
str::posIgnoreCase(string $string, string $search, int $fromIndex): int
The same method as pos() only with ignoring case characters
str::lastPos(string $string, string $search, null|int $fromIndex): int
Returns the index within this string of the last occurrence of the specified substring. The last occurrence of the empty string "" is considered to occur at the index value $string.length.
str::lastPosIgnoreCase(string $string, string $search, null|int $fromIndex): int
The same method as lastPos()
only with ignoring case characters
str::sub(string $string, int $beginIndex, null|int $endIndex): string
Returns a new string that is a substring of this string. The
substring begins at the specified $beginIndex
and
extends to the character at index $endIndex
- 1.
Thus the length of the substring is endIndex - beginIndex
.
str::compare(string $string1, string $string2): int
Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings.
The character sequence represented by $string1
String
is compared lexicographically to the
character sequence represented by $string2
. The result is
a negative integer if $string1
lexicographically precedes $string2
. The result is a
positive integer if $string1
lexicographically
follows $string2
. The result is zero if the strings
are equal; compare
returns 0 exactly when
the strings are equal
str::compareIgnoreCase(string $string1, string $string2): int
The same method as compare()
only with ignoring case characters
str::equalsIgnoreCase(string $string1, string $string2): bool
Checks that the strings are equal with ignoring case characters
str::startsWith(string $string, string $prefix, int $offset): bool
Tests if the substring of this string beginning at the specified index starts with the specified prefix.
Returns true if the character sequence represented by the
argument is a prefix of the substring of this object starting
at index offset
; false
otherwise.
The result is false
if toffset
is
negative or greater than the length of this
$string
; otherwise the result is the same
as the result of the expression
.. code-block:: php
startsWith(sub($offset), $prefix)
str::endsWith(string $string, string $suffix): bool
Tests if this string ends with the specified suffix.
str::lower(string $string): string
Converts all of the characters in $string
to lower
case using the rules of the default locale.
str::upper(string $string): string
Converts all of the characters in $string
to upper
case using the rules of the default locale.
str::length(string $string): int
Returns the length of $string
.
The length is equal to the number of Unicode code units
in the string.
str::replace(string $string, string $target, string $replacement): string
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaa" will result in "ba" rather than "ab".
str::repeat(string $string, int $amount): string
Return s a new string consisting of the original $string
repeated
str::trim(string $string, string $charList): string
Returns a copy of the string, with leading and trailing whitespace omitted.
str::trimRight(string $string, string $charList): string
str::trimLeft(string $string, string $charList): string
str::reverse(string $string): string
Reverse the string.
str::shuffle(string $string): string
Returns a randomized string based on chars in $string
str::random(int $length, string $set): string
Returns a new random string based on set.
str::split(string $string, string $separator, int $limit): array
The method like explode() in Zend PHP.
str::join(array|\Iterator $iterable, string $separator, int $limit): string
The method like implode()
in Zend PHP.
str::encode(string $string, string $charset): string
Converts $string by using $charset and returns a binary string.
str::decode(string $string, string $charset): string
Decodes $string by using $charset to UNICODE, returns a unicode string.
str::isNumber(string $string, bool $bigNumbers): bool
Returns true if $string is integer number (e.g: '12893', '3784', '0047')
- for
123
- true - for
00304
- true - for
3389e4
- false - for
3.49
- false - for
23
- false
str::isLower(string $string): bool
str::isUpper(mixed $string): bool
str::lowerFirst(string $string): string
str::upperFirst(string $string): string
str::parseAs(string $string, string $format, int $flags): mixed
Parse text as json, ini, yaml, etc.
str::formatAs(mixed $input, string $format, int $flags): string
Format value as ini, json, yml, etc.
str::format(string $string, mixed $args): string
str::contains(string $string, string $search): bool
Returns true if string contains a substring.
str::count(string $string, string $subString, int $offset): int
Возвращает количество найденный строк в другой строке.
str::uuid(null|string $value): string
str::hash(string $string, string $algorithm): string
Возвращает хеш строки.
str::lines(string $string, bool $removeEmpty): array
Переводит многострочный текст в массив, если $removeEmpty true, то удаляет пустые строки из результата.
__construct(): void