Share on Google+Share on Google+

The strpos() function

Advertisement
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.

Advertisements

Posted on: February 1, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.