PHP strpos() Function

The strpos() function finds the position of the first occurrence of a string inside another string.

int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )

Find the numeric position of the first occurrence of needle in the haystack string.

Example -

Example #1 Using ===

Example #2 Using !==

Example #3 Using an offset

ParameterDescription
haystackThe string to search in.
needleIf needle is not a string, it is converted to an integer and applied as the ordinal value of a character.
offsetIf specified, search will start this number of characters counted from the beginning of the string. If the offset is negative, the search will start this number of characters counted from the end of the string.

Returns the position of where the needle exists relative to the beginning of the haystack string (independent of offset). Also note that string positions start at 0, and not 1.