php procurar se o sub-texto está no texto
$result = strpos("haystack", "needle");
if ($result != false)
{
// text found
}
o texto do php contém
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
php verificar se o texto contém
// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}
Como posso verificar se um texto contém uma palavra específica?
$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}