“PHP -Zeichenfolge enthält Substring” Code-Antworten

PHP -Zeichenfolge enthält Substring

$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
    echo "My string contains Bob";
}
Grepper

PHP -Zeichenfolge enthält

$string = 'The lazy fox jumped over the fence';

if (str_contains($string, 'lazy')) {
    echo "The string 'lazy' was found in the string\n";
}

TomatenTim

Wie überprüfe ich, ob eine Zeichenfolge ein bestimmtes Wort PHP enthält

$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}
Indian Gooner

So überprüfen Sie, ob eine Zeichenfolge ein Substring in PHP enthält

$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}
Samson Munyira

PHP, wenn String enthält

if (str_contains('How are you', 'are')) { 
    echo 'true';
}
nanaseous

Überprüfen Sie, ob die Zeichenfolge Zeichen -PHP enthält

// this method is new with PHP 8 and above
$haystack = "Damn, I wonder if this string contains a comma.";
if (str_contains($haystack, ",")) {
	echo "There is a comma!!";
}
Lonely Doge

Ähnliche Antworten wie “PHP -Zeichenfolge enthält Substring”

Fragen ähnlich wie “PHP -Zeichenfolge enthält Substring”

Weitere verwandte Antworten zu “PHP -Zeichenfolge enthält Substring” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen