Current Location: Home> Function Categories> strpos

strpos

Find the first occurrence of substrings in strings
Name:strpos
Category:String
Programming Language:php
One-line Description:Returns where the string first appears in another string (case sensitive).

Definition and usage

strpos() function finds where the string first appears in another string.

Note: strpos() function is case sensitive.

Note: This function is binary safe.

Related functions:

  • stripos() - Find where the string first appears in another string (case insensitive)
  • strripos() - Find the last occurrence of a string in another string (case insensitive)
  • strrpos() - Find the last occurrence of a string in another string (case sensitive)

Example

Find the first occurrence of "php" in the string:

 <?php
echo strpos ( "You love php, I love php too!" , "php" ) ;
?>

Try it yourself

grammar

 strpos ( string , find , start )
parameter describe
string Required. Specifies the string to search.
Find Required. Specifies the string to be searched.
start Optional. Specify where to start the search.
Similar Functions