Character search function in php. The stristr () function is used to locate the first occurrence of a string in another string. If successful, the rest of the string is returned (from the matching point ). If the stristr () function does not find the position where the string first appears in another string.
If successful, the rest of the string is returned (from the matching point ). If this string is not found, false is returned.
Syntax
Stristr (string, search)
*/
$ Str = "hello world"; // define a string
$ Result = stristr ($ str, "w"); // perform the search operation
Echo $ result; // output the search result, which will output "world"
/*
The stripos () function returns the position where the string first appears in another string.
If this string is not found, false is returned.
Syntax
Stripos (string, find, start)
*/
$ Str = "hello world"; // define a string
$ Result = stripos ($ str, "w"); // perform the search operation.
Echo $ result; // output the search result, which is 6
/*
*/
$ Str = "hello world"; // define a string
$ Result = stripos ($ str, "l"); // perform the search operation.
Echo $ result; // output the search result. 2 is returned.
/*
The strspn () function returns the number of specific characters contained in the string.
Syntax
Strspns (string, charlist, start, length)
*/
$ Str = "hello world"; // define a string
$ Result = strspn ($ str, "khlleo"); // search for the length that meets the condition
Echo $ result; // Number of output result lengths. 5 is returned.
/*
*/
$ Str = "hello world! ??? "; // Define a string
Echo $ str ."
"; // Output the original string
Echo convert_cyr_string ($ str, 'W', 'A'); // output the converted string "hello world! ?.? "
The http://www.bkjia.com/PHPjc/631717.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/631717.htmlTechArticlestristr () function looks for the position where the string first appears in another string. If successful, the rest of the string is returned (from the matching point ). If this string is not found...