There are several string handling functions that can do what you want. cLFlaVA has shown the use of strpos - which indirectly tells you that the "needle" is contained in the haystack by returning its relative position.
There is also strstr($hastack,$needle) which returns the part of the haystack beginning with the first occurrence of needle.
The logic in both cases is the same. If the function returns something else than "false" (which menas not found) then you can conclude that the needle was part of the haystack.
For more complicated patterns than simple strings PHP offers PCRE (Perl COmpatible Regular Expressions).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.