robcrozier Posted March 8, 2007 Share Posted March 8, 2007 Hi, can anyone tell me how i can check to see if a large string contains a substring in any position at all, by this i mean that the substring could occur at the start, middle or end of the actual string. If the substring is found i would then like a flag to be raised. maybe using a boolean or something. thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/41798-how-to-tell-if-a-string-contains-a-substring/ Share on other sites More sharing options...
skali Posted March 8, 2007 Share Posted March 8, 2007 strpos ( 'search_string', 'str') Quote Link to comment https://forums.phpfreaks.com/topic/41798-how-to-tell-if-a-string-contains-a-substring/#findComment-202703 Share on other sites More sharing options...
robcrozier Posted March 8, 2007 Author Share Posted March 8, 2007 ho exactly does this function work though and how do i work with the output? cheers Quote Link to comment https://forums.phpfreaks.com/topic/41798-how-to-tell-if-a-string-contains-a-substring/#findComment-202705 Share on other sites More sharing options...
skali Posted March 8, 2007 Share Posted March 8, 2007 int strpos ( string haystack, mixed needle [, int offset] ) Returns the numeric position of the first occurrence of needle in the haystack string. Unlike the strrpos(), this function can take a full string as the needle parameter and the entire string will be used. www.php.net/function.strpos Quote Link to comment https://forums.phpfreaks.com/topic/41798-how-to-tell-if-a-string-contains-a-substring/#findComment-202708 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.