PHP strpos() Function
Example
Find the first occurrence of "php" in the string:
<?php echo strpos("You love php, I love php too!","php"); ?>
Definition and Usage
The strpos() function finds the first occurrence of the string in another string.
Note:The strpos() function is case-sensitive.
Note:This function is binary safe.
Related Functions:
- stripos() - Find the first occurrence of the string in another string (case-insensitive)
- strripos() - Find the last occurrence of the string in another string (case-insensitive)
- strrpos() - Find the last occurrence of the string in another string (case-sensitive)
Syntax
strpos(string,find,start)
Parameters | Description |
---|---|
string | Required. Specifies the string to be searched. |
find | Required. Specifies the string to be searched for. |
start | Optional. Specifies where to start the search. |
Technical Details
Return Value: |
Returns the position of the first occurrence of the string in another string, or FALSE if the string is not found. Note:String positions start from 0, not from 1. |
PHP Version: | 4+ |