Python has the great: if sub-string in string, like this:
if "fox" in "The quick brown fox jumps over the lazy dog":
print True
Does does PHP have something equivalent to this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, see stripos and strpos
stripos and strpos return the position at which the match started, so you need to use strict comparison (=== or !==) to avoid a false negative when the needle is at pos. 0 in the haystack.
You may prefer stristr, which just returns the matched string or boolean false.
in_array works about the same as
indoes in Python for lists and dictionaries, if you are also thinking beyond strings.