PHP Strpos Function
PHP Strpos Function
com LOG IN
Example
Find the position of the first occurrence of "php" inside the string:
<?php
echo strpos("I love php, I love php too!","php");
?>
Try it Yourself »
Related functions:
strrpos() - Finds the position of the last occurrence of a string inside another string (case-sensitive)
stripos() - Finds the position of the first occurrence of a string inside another string (case-insensitive)
strripos() - Finds the position of the last occurrence of a string inside another string (case-insensitive)
Syntax
strpos(string,find,start)
Parameter Values
Parameter Description
start Optional. Specifies where to begin the search. If start is a negative number, it counts from the
end of the string.
Technical Details
Return Value: Returns the position of the first occurrence of a string inside another string, or FALSE if the
string is not found. Note: String positions start at 0, and not 1.
PHP Version: 4+
Get certified
by completing
a course today!
school
w3 s
1
CE
02
TI 2
R
FI .
ED
Get started
CODE GAME
Play Game
Certificates
HTML
CSS
JavaScript
Front End
Python
SQL
And more
-36%
Chaldal.com
Get Certified »
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples
are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and
accepted our terms of use, cookie and privacy policy.