“La chaîne PHP contient des chaînes” Réponses codées

PHP Vérifiez si la chaîne contient un mot

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

Comment puis-je vérifier si une chaîne contient un mot spécifique php

$a = 'How are you?';

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

Comment vérifier si une chaîne contient une sous-chaîne en php

$a = 'How are you?';

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

php si la chaîne contient

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

Vérifiez si la chaîne contient le caractère php

// 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

La chaîne PHP contient des chaînes

$str = 'Hello World!';

if (strpos($str, 'World') !== false) {
    echo 'true';
}
Snippets

Réponses similaires à “La chaîne PHP contient des chaînes”

Questions similaires à “La chaîne PHP contient des chaînes”

Plus de réponses similaires à “La chaîne PHP contient des chaînes” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code