PHP stripos() Function

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

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

Find the numeric position of the first occurrence of needle in the haystack string.Unlike the strpos(), stripos() is case-insensitive.

Related functions:

  • strripos() - Finds the position of the last occurrence of a string inside another string (case-insensitive)
  • strpos() - Finds the position of the first occurrence of a string inside another string (case-sensitive)
  • strrpos() - Finds the position of the last occurrence of a string inside another string (case-sensitive)

Example -

ParameterDescription
haystackThe string to search in.
needleNote that the needle may be a string of one or more characters.If 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 beginnning of the haystack string (independent of offset). Also note that string positions start at 0, and not 1.Returns FALSE if the needle was not found.