Reader Level:

Difference Between Strpos and Stripos Function

By Vinod Kumar on Dec 26, 2012
In this article I am going to explain string functions in PHP.


The strpos() function finds the position of a string and the stripos() function is the same as the strpos() function but is used for a case-insensitive search. Both return the position of the first occurrence of a string inside another string.
If the string is not found, this function returns FALSE. The strpos() function is used to find a string position in a string. The strpos() function will return with the position of the first match, not every match in the string.


strpos(what to search, what to search for);



strpos("Hello Sharad kumar!","S");

The problem there is that strpos() matches the first "S" it comes across, which will be in "This". Fortunately there is a third parameter to strpos() that allows us to specify where to start from. As the "S" in "This" is at index 2, we just need to specify one place after that (3) as the start position for strpos(), and it will report back the next "S" after it



Note: The strpos() function is case-sensitive. Being able to manipulate strings is a valuable skill, especially in PHP. You'll most likely come across a programming problem that requires you to find some data in a string. The beginning of a lot of your string manipulation expertise will begin with the strpos function, which allows you to find data in your string. One of the limitations of strpos is that it only returns the position of the very first match.






echo Stripos("Hello Sharad kumar!","K");




Note: But stripos() function case-insensitive.

Vinod  Kumar
Vinod Kumar

       Hi every one I am MCA qualified from IGNOU, Currently working as a Senior software Engineer at dogSpot pvt ltd gurgaon having 3+ year experience and also like web designing ... Read more



Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.

Trending up