Reputation: 5089
I want to check whether a string is present in another string, and then take the appropriate action. What is the best way to do this?
For instance; if the string 'europe' is present in 'europeisthebest', then do something.
if ( isIn('europe', 'europeisthebest') == true){
//do something
}
Thank you a lot! I appreciate all of your answers and time spent helping.
Upvotes: 4
Views: 6564
Reputation: 1908
You can also use the function strpos() if you wish to know the position of the substring inside the string
Upvotes: 0
Reputation: 219834
You're looking for strstr()
(case sensitive), stristr()
(case insenstive), or strpos()
if (stristr('europeisthebest', 'europe')){
// do something
}
Upvotes: 12