How to search text using php if ($text contains "World")
What you need is strstr()
(or stristr()
, like LucaB pointed out). Use it like this:
if(strstr($text, "world")) {/* do stuff */}
In your case you can just use strpos()
, or stripos()
for case insensitive search:
if (stripos($text, "world") !== false) {
echo "True";
}