Find the first occurrence of "php" in a string:
<?phpecho stripos("I love php, I love php too!","PHP");?>The stripos() function finds the first occurrence of a string within another string (case-insensitive).
Note: The stripos() function is not case sensitive.
Note: This function is binary safe.
Related functions:
strripos() - Finds the last occurrence of a string within another string (case insensitive)
strpos() - finds the first occurrence of a string within another string (case sensitive)
strrpos() - Finds the last occurrence of a string within another string (case sensitive)
stripos( string,find,start )
parameter | describe |
---|---|
string | Required. Specifies the string to be searched for. |
find | Required. Specifies the characters to search for. |
start | Optional. Specifies the location to start the search. |
Return value: | Returns the position of the first occurrence of a string in another string, or FALSE if the string is not found. Note: The string position starts from 0, not from 1. |
---|---|
PHP version: | 5+ |