Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP stripos() function is used to return the index number of first occurrence of specified text in the given string. Unlike strpos function, it is not a case-sensitive function.

Note: The stripos() function is not a case-sensitive function.

Syntax

stripos(string, find, start)

Parameters

string Required. Specify the string to search.
find Required. Specify the string to find.
start Optional. Specify the index number from where the search need to start.

Return Value

Returns the index number of first occurrence of specified text in the given string.

Example:

In the below example, stripos() function to used to find the index number of first occurrence of "be" in the given string called MyString.

<?php
  $MyString = "To be, or not to be, that is the question.";

  echo stripos($MyString, "be")."\n";
?>

The output of the above code will be:

3

Example:

In the below example, first occurrence of "be" is searched after the specified strating position.

<?php
  $MyString = "To be, or not to be, that is the question.";

  echo stripos($MyString, "be", 5)."\n";
?>

The output of the above code will be:

17

❮ PHP String functions