Home >>PHP String Functions >PHP stripos() Function
PHP stripos() function is used to find the position of the first occurrence of a given input string in another string.It return an integer value of the position of the first occurrence of the input string. It is case-insensitive. The case-sensitive version of this function is strpos() function.
Syntax:
stripos($string, $search, $start);
Parameter | Description |
---|---|
string | This is a required parameter. This parameter defines the string to search. |
search | This is a required parameter. This parameter defines the string to search for. |
start | This is an optional parameter. This parameyter defines where to begin the search. |
Here is an example of stripos() function in PHP:
<html> <body> <?php echo stripos("Welcome to PHPTPOINT","php"); // case in-sensitive ?> </body> </html>
Here is an example of stripos() function in PHP:
<html> <body> <?php $str = "Hello Everyone.. Welcome to PHPTPOINT"; echo stripos($str,"welcome",0); echo "<br>"; echo stripos($str,"welcome",15); echo "<br>"; echo stripos($str,"welcome",20); // not found because start position is 20. ?> </body> </html>