str¶
-
php\lib\str
Class str
Methods
__construct
()¶private
- static
pos
($string, $search, $fromIndex = 0)¶Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Параметры:
- $string –
string
- $search –
string
- the substring to search for- $fromIndex –
int
- the index from which to start the search.Результат:
int
- returns -1 if not found
- static
posIgnoreCase
($string, $search, $fromIndex = 0)¶The same method as
pos()
only with ignoring case characters
Параметры:
- $string –
string
- $search –
string
- the substring to search for.- $fromIndex –
int
- the index from which to start the search.Результат:
int
- returns -1 if not found
- static
lastPos
($string, $search, $fromIndex = null)¶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
.
Параметры:
- $string –
string
- $search –
string
- the substring to search for.- $fromIndex –
null
,int
- - null means $fromIndex will be equal $string.lengthРезультат:
int
- returns -1 if not found
- static
lastPosIgnoreCase
($string, $search, $fromIndex = null)¶The same method as
lastPos()
only with ignoring case characters
Параметры:
- $string –
string
- $search –
string
- the substring to search for.- $fromIndex –
null
,int
- - null means $fromIndex will be equal $string.lengthРезультат:
int
- static
sub
($string, $beginIndex, $endIndex = null)¶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 isendIndex - beginIndex
.
Параметры:
- $string –
string
- $beginIndex –
int
- $endIndex –
null
,int
- When$endIndex
equals tonull
then it will be equal$string.length
Результат:
string
- return false if params are invalid
- static
compare
($string1, $string2)¶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
Параметры:
- $string1 –
string
- - first string- $string2 –
string
- - second stringРезультат:
int
- static
compareIgnoreCase
($string1, $string2)¶The same method as
compare()
only with ignoring case characters
Параметры:
- $string1 –
string
- $string2 –
string
Результат:
int
- static
equalsIgnoreCase
($string1, $string2)¶Checks that the strings are equal with ignoring case characters
Параметры:
- $string1 –
string
- $string2 –
string
Результат:
bool
- static
startsWith
($string, $prefix, $offset = 0)¶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 indexoffset
;false
otherwise. The result isfalse
iftoffset
is negative or greater than the length of this$string
; otherwise the result is the same as the result of the expressionstartsWith(sub($offset), $prefix)
Параметры:
- $string –
string
- $prefix –
string
- $offset –
int
- where to begin looking in this stringРезультат:
bool
- static
endsWith
($string, $suffix)¶Tests if this string ends with the specified suffix.
Параметры:
- $string –
string
- $suffix –
string
Результат:
bool
- static
lower
($string)¶Converts all of the characters in
$string
to lower case using the rules of the default locale.
Параметры:
- $string –
string
Результат:
string
- static
upper
($string)¶Converts all of the characters in
$string
to upper case using the rules of the default locale.
Параметры:
- $string –
string
Результат:
string
- static
length
($string)¶Returns the length of
$string
. The length is equal to the number of Unicode code units in the string.
Параметры:
- $string –
string
Результат:
int
- static
replace
($string, $target, $replacement)¶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”.
Параметры:
- $string –
string
- $target –
string
- The sequence of char values to be replaced- $replacement –
string
- The replacement sequence of char valuesРезультат:
string
- static
repeat
($string, $amount)¶Return s a new string consisting of the original
$string
repeated
Параметры:
- $string –
string
- $amount –
int
- number of times to repeat strРезультат:
string
trim($string, $charList = '
‘)
Returns a copy of the string, with leading and trailing whitespace omitted.
param $string: string
param $charList: string
returns: string
trimRight($string, $charList = '
‘)
param $string: string
param $charList: string
returns: string
trimLeft($string, $charList = '
‘)
param $string: string
param $charList: string
returns: string
- static
reverse
($string)¶
Параметры:
- $string –
string
Результат:
string
- static
shuffle
($string)¶Returns a randomized string based on chars in $string
Параметры:
- $string –
string
Результат:
string
- static
random
($length = 16, $set = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789')¶
Параметры:
- $length –
int
- $set –
string
Результат:
string
- static
split
($string, $separator, $limit = 0)¶The method like
explode()
in Zend PHP
Параметры:
- $string –
string
- $separator –
string
- $limit –
int
Результат:
array
- static
join
($iterable, $separator, $limit = 0)¶The method like
implode()
in Zend PHP
Параметры:
- $iterable –
array
,php\lib\\Iterator
- $separator –
string
- $limit –
int
Результат:
string
- static
encode
($string, $charset)¶Converts $string by using $charset and returns a binary string
Параметры:
- $string –
string
- $charset –
string
- e.g. UTF-8, Windows-1251, etc.Результат:
string
binary string
- static
decode
($string, $charset)¶Decodes $string by using $charset to UNICODE, returns a unicode string
Параметры:
- $string –
string
- $charset –
string
- e.g. UTF-8, Windows-1251, etc.Результат:
string
binary string
- static
isNumber
($string, $bigNumbers = true)¶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
Параметры:
- $string –
string
- $bigNumbers –
bool
Результат:
bool
- static
isLower
($string)¶
Параметры:
- $string –
string
Результат:
bool
- static
isUpper
($string)¶
Параметры:
- $string –
Результат:
bool
- static
lowerFirst
($string)¶
Параметры:
- $string –
string
Результат:
string
- static
upperFirst
($string)¶
Параметры:
- $string –
string
Результат:
string
- static
format
($string, $args)¶
Параметры:
- $string –
string
- $args –
Результат:
string
- static
contains
($string, $search)¶
Параметры:
- $string –
string
- $search –
string
Результат:
bool
- static
count
($string, $subString, $offset = 0)¶
Параметры:
- $string –
string
- $subString –
string
- $offset –
int
Результат:
int
- static
uuid
($value = null)¶
Параметры:
- $value –
null
,string
Результат:
string
uuid of $value if it is not null, else random uuid
- static
hash
($string, $algorithm = 'SHA-1')¶throws
php\lib\\Exception
if the algorithm is not supported
Параметры:
- $string –
string
- $algorithm –
string
- MD5, SHA-1, SHA-256, etc.Результат:
string