Javatpoint Logo
Javatpoint Logo

PHP strpos() Function

The strops() is in-built function of PHP. It is used to find the position of the first occurrence of a string inside another string or substring in a string.

Syntax:

Parameter Description Required/Optional
string Specify the string to search. Start
find Specify the string to find. Required
start Specify where to begin the search. Optional

This function will help us to find the numeric position of the first occurrence of needle in the haystack string

Note: The strops() function is case-sensitive and binary-safe.

Example 1

Output:

First string is: Hello Php
First string is: Hello Php javatpoint!
By using 'strpos()' function:

Example 2

Output:

First string is: Hello php
First string is: Hello php javatpoint!
By using 'strpos()' function:6

Example 3

Output:

The string 'Hello' was found in the string 'Hello PHP'
and exists at position 0

See Also:

strchr() : It is used to find the first occurrence of a string inside another string.

stscroll() : It is locale based string comparison.

strcmp() : It is binary safe string comparison.

Reference:

http://php.net/manual/en/function.strpos.php


Next TopicPHP String




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA