Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP strpos() Function

PHP strpos() Function

PHP String Reference Manual PHP String Reference Manual

Example

Find the first position of "php" in a string:

Run Example »


Definition and Usage

The strpos() function finds the first occurrence of a string within another string (case-sensitive).

**Note:** The strpos() function is case-sensitive.

**Note:** This function is binary-safe.

Related functions:


Syntax

strpos(

string,find,start

)

Parameters Description
string Required. Specifies the string to be searched.
find

Required. Specifies the characters to find.

start Optional. Specifies the position to start searching.

Technical Details

Return Value: Returns the position of the first occurrence of a string within another string, or FALSE if the string is not found.Note: String positions start at 0, not 1.
PHP Version: 4+

PHP String Reference Manual PHP String Reference Manual