- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
strpos() function in PHP
The strpos() function is used to find the position of first occurrence of a string inside another string.
Syntax
strpos(str, find, begin)
Parameters
str − The string to search
find − The string to find
begin − Where to begin the search
Return
The strpos() function returns the position of first occurrence of a string inside another string or else false if string is not found.
Example
The following is an example −
<?php echo strpos("This is demo text !","demo"); ?>
Output
The following is the output −
8
Example
Let us see another example −
<?php $str = 'pqr pqr'; $pos = strpos($str, 'p', 1); echo $pos; ?>
Output
The following is the output −
4
Advertisements
To Continue Learning Please Login
Login with Google