FUNCTION NAME |
FUNCTION DESCRIPTION |
FUNCTION SYNTAX |
FUNCTION RETURN VALUE |
strrchr()
[Find the last occurrence of a character in a string] |
This function returns the portion of the haystack string which starts at the last [‘reverse’] occurrence of the needle character and continues till the end of haystack. |
strrchr(haystack, needle);
[If needle comprises more than one character, only the first one is used; this behaviour differs from strstr() . If needle is not a string it is converted to an integer and applied as the ordinal value of a character.] |
strrchr() : returns the portion of string, or FALSE if needle is not found. |
strrev()
[Reverse a string] |
This function returns string, reversed. |
strrev(string); |
strrev() : returns the reversed string. |
strripos()
[Find the position of the last occurrence of a case-insensitive substring in a string] |
This function finds the numeric position of the last [‘reverse’] case-insensitive occurrence of needle in the haystack string. |
strripos(haystack, needle, offset [optional parameter with a default value of 0]) ;
[needle may be a string of one or more characters; if it is not a string, it is converted to an integer and applied as the ordinal value of a character. If offset is specified and positive, searching will begin this number of characters counted from the beginning of haystack; if negative, searching will begin this number of characters counted from the end of haystack.] |
strripos() : returns the position of where the last [‘reverse’] case-insensitive needle exists relative to haystack [independent of offset]. String positions start at 0 and not 1. Returns FALSE if needle was not found. |
strrpos()
[Find the position of the last occurrence of a case-sensitive substring in a string] |
This function finds the numeric position of the last [‘reverse’] case-sensitive occurrence of needle in the haystack string. |
strrpos(haystack, needle, offset [optional parameter with a default value of 0]) ;
[needle may be a string of one or more characters; if it is not a string, it is converted to an integer and applied as the ordinal value of a character. If offset is specified and positive, searching will begin this number of characters counted from the beginning of haystack; if negative, searching will begin this number of characters counted from the end of haystack.] |
strrpos() : returns the position of where the last [‘reverse’] case-sensitive needle exists relative to haystack [independent of offset]. String positions start at 0 and not 1. Returns FALSE if needle was not found. |
strspn()
[Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask] |
This function finds the length [‘span’] of the initial segment of subject string consisting entirely of characters contained within a given mask. If start and length are omitted, then all of subject will be examined. If start and length are included, then the effect will be the same as calling strspn(substr($subject, $start, $length), $mask) . |
strspn(subject, mask, start [optional parameter], length [optional parameter]);
[If start is specified and is positive, strspn() will begin examining subject from the startth position. If start is negative, strspn() begins examining subject start positions from the end of the string. If length is given and is non-negative, strspn() examines subject for length characters after the starting position. If length is negative, subject will be examined from start up to length characters from the end of subject.] |
strspn() : returns the length [‘span’] of the initial segment of subject string which consists entirely of characters in mask. When a start parameter is set, length is counted from this starting position – not from the beginning of subject. |
strtok()
[Tokenize string] |
This function splits string into smaller strings [tokens], with each of these smaller strings being delimited by any character from token. Only the first call to strtok() uses the string argument; each subsequent call only needs the token to use, since it keeps track of where it is in the current string. To start again – or to tokenize a new string – simply call strtok() with the string argument again to initialize it. Multiple tokens are permitted in the token parameter; the string will be tokenized when any one of the characters in the argument is found. |
First function call:
strtok(string, token);
Subsequent function calls:
strtok(token); |
strtok() : returns a string token. |
strtolower()
[Make a string lowercase] |
This function returns string with all alphabetic characters converted to lowercase. ‘Alphabetic’ is determined by the current locale: in the default C locale, characters such as umlaut-A – for example – will not be converted. |
strtolower(string); |
strtolower() : returns string converted to lowercase. |
strtoupper()
[Make a string uppercase] |
This function returns string with all alphabetic characters converted to uppercase. ‘Alphabetic’ is determined by the current locale: in the default C locale, characters such as umlaut-A – for example – will not be converted. |
strtoupper(string); |
strtoupper() : returns string converted to uppercase. |
strtr()
[Translate characters or replace substrings] |
If passed three arguments, this function returns a copy of string where all occurrences of each [single-byte] character in from have been translated to the corresponding character in to, videlicet– every occurrence of $from[$n] has been replaced with $to[$n] , where n is a valid offset in both arguments. If from and to have different lengths, the extra characters in the longer of the two will be ignored; the length of string will be the same as the return value’s. |
With three arguments:
strtr(string, from, to);
With two arguments:
strtr(string, replace_array);
[If given two arguments, the replace_array should be of the form array('from' => 'to') . The return value is a string where all occurrences of the array keys have been replaced by the corresponding array values. The longest keys will be tried first; once a substring has been replaced, its new value will not be searched again. The keys and values may have any length, provided that there is no empty key; the length of the return value may differ from that of string. This function will be most efficient when all the keys have the same size.] |
strtr() : returns the translated string on success. If replace_array contains a key which is an empty string, FALSE is returned. If string is not scalar it is not typecasted into a string; instead a warning is raised and NULL is returned. |
substr_compare()
[Binary safe comparison of two strings from an offset, up to length characters] |
This function compares main_string – from position offset – with second_string [‘substring’] [up to length characters]. |
substr_compare(main_string, second_string, offset, length [optional parameter, with a default value equal to the largest of *length of second_string*/*main_string – offset], case_insensitivity [optional parameter with a default value of FALSE]);
[offset specifies the position at which to start counting. If negative, the comparison begins at offset characters from the end of the string.] |
substr_compare() : returns <0 if main_string from position offset is less than second_string; returns >0 if main_string from position offset is greater than second_string; returns 0 if main_string from position offset is equal to second_string. A WARNING is printed and FALSE is returned if offset is equal to or greater than the length of main_string, or the length is set and less than 1 in PHP versions prior to 5.5.11. |