PHP string function strpos

The String function strpos(), finds the position of very first occurrence of any substring in the given string.

PHP string function strpos

Syntax

Parameter   Description
string_value This is a required parameter which defines the string to search.
sub_string_value This is a required parameter which defines the string to find.
start_position  This is an optional parameter which defines from where to begin the search.

Return Value

It will return the position of the sub string in the given string and return FALSE if sub string not found in the string.

Example 1 using === (Identical Operator)

Example 2 using !== (Not identical Operator)

Example 3 using an string start  position

 

NOTE: String position starts from zero (0) and not from one (1)

NOTE: This function is binary-safe.

PHP Version: PHP 4, PHP 5, PHP 7