The strpos() function


 

The strpos() function

This section contains the detail about strpos() function in PHP.

This section contains the detail about strpos() function in PHP.

The strpos() function

The strpos() function is used to find the availability of a sub string/string inside a string.

This function returns FALSE ,if the string or sub string provided is not found.

The syntax of the above method is given below :

strpos(string, find, start)

Here, string is the string in which we search sub string. The  find is the sub string or string which we search inside another string. The start is optional argument and it specifies where to begin the search.

The below example will give you a clear idea :

Example :

<?php
echo strpos("Hello PHP!","PHP");
?>

Output :

 6

Since index starts with 0 that is why it shows 6. As in normal counting it is at 7th place.

Ads