In php, the strposstrrchrstrpbrk character search function strpos () returns the position where the string first appears in another string. if the string is not found, false is returned.
Syntax: strpos (string, find, start). The code is as follows:
$ Str = "hello world"; // defines string 1
$ Result = strpos ($ str, "ll"); // execute the following command to find the earliest location
Echo $ result; // output result, 2
The strrchr () function is used to locate the last occurrence position of a string in another string and return all characters from this position to the end of the string. if the result fails, false is returned.
Syntax: strrchr (string, char). The code is as follows:
$ Str = "hello world"; // defines string 1
$ Result = strrchr ($ str, "o"); // run the following command to find the last position.
Echo $ result;
The strpbrk () function searches for any of the specified characters in a string. This function returns the remainder of the position at which the specified character first appears. if not found, false is returned.
Syntax: strpbrk (string, charlist). The code is as follows:
$ Str = "hello world"; // defines string 1
$ Result = strpbrk ($ str, "oe"); // perform the search operation.
Echo $ result; // output result, ello world
// Open source code phpfensi.com
Prompt and comment.
Note: This function is case sensitive.