strpos
Finds the position of the first occurrence of a substring within a string.
Parameters
main.php
Return Values
int|false
Returns the position as integer or false if not found
On success:Integer position of the first occurrence (0-indexed)
On failure:false if needle is not found in haystack
Notes
- Returns 0 for matches at the beginning - use strict comparison (=== false)
- Function is case-sensitive, use stripos() for case-insensitive search
- Offset parameter allows starting search from specific position
- Use mb_strpos() for multibyte string handling
Changelog
- 8.0.0: Passing int as needle is deprecated
- 7.1.0: Support for negative offsets
Related Functions
array_search
ArraySearches an array for a specific value and returns the corresponding key if found, or false if not found.
searchfindkey
in_array
ArrayChecks if a value exists in an array.
searchexistsvalidate