PHP strpos() Function is used to find the position of the first occurrence of a substring in a string. PHP strpos() function is PHP built-in function.
PHP Version : PHP 4, PHP 5, PHP 7, PHP 8
Syntax for strpos :
strpos(string $string, string $search, int $start);
$string : Required. It is the string to be searched.
$search : Required. It is value to search.
$start: Optional. It specifies where to begin the search. Search will start at the beginning of the string. If the $start is negative, the search will start at the end of the string.
Return values for strpos :
A strpos() Function returns the position of the first occurrence of a string inside another string. It also returns FALSE if the string is not found. String positions always starts at 0.
The strpos() function is case-sensitive. You can also use stripos() Function for case-insensitive.
Let's see below example to understand php strpos() Function in details.