A sub-estrutura do php existe no texto

Exemplos de código

5
0

php procurar se o sub-texto está no texto

$result = strpos("haystack", "needle");

if ($result != false)
{
  // text found
}
5
0

o texto do php contém

$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
2
0

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;
}
2
0

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';
}

Páginas relacionadas

Páginas semelhantes com exemplos

Em outros idiomas

Esta página está em outros idiomas

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................