PHP Sprawdź, czy ciąg zawiera słowo
$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
echo "My string contains Bob";
}
Grepper
$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
echo "My string contains Bob";
}
$string = 'The lazy fox jumped over the fence';
if (str_contains($string, 'lazy')) {
echo "The string 'lazy' was found in the string\n";
}
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}
if (str_contains('How are you', 'are')) {
echo 'true';
}
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);