strpos()
Finds the position of a substring.
Syntax
strpos($text, $part)
Description
Returns the starting position of the part (from 0); returns false if not found.
Example
Loading editor…
Expected output
2
When to use?
Searching, checking if a word exists.
Common mistakes
- ⚠️ Don't confuse position 0 with false; check with === (if (strpos(...) !== false)).