“php trouver si la chaîne contient des mots de la liste index” Réponses codées

PHP Vérifiez si la chaîne contient des mots du tableau

$string = "This dude is a mean mothertrucker";
$badwords = array('truck', 'shot', 'ass');
$banstring = ($string != str_ireplace($badwords,"XX",$string))? true: false;
if ($banstring) {
   echo 'Bad words found';
} else {
    echo 'No bad words in the string';
}
Borma

php trouver si la chaîne contient des mots de la liste index

$owned_urls = array('website1.com', 'website2.com', 'website3.com');

//this example should return FOUND
$string = 'my domain name is website3.com';
if (array_in_string($string, $owned_urls)) {
    echo "first: Match found<br>"; 
}
else {
    echo "first: Match not found<br>";
}

//this example should return NOT FOUND
$string = 'my domain name is website4.com';
if (array_in_string($string, $owned_urls)) {
    echo "second: Match found<br>"; 
}
else {
    echo "second: Match not found<br>";
}
Weary Wildebeest

Réponses similaires à “php trouver si la chaîne contient des mots de la liste index”

Questions similaires à “php trouver si la chaîne contient des mots de la liste index”

Plus de réponses similaires à “php trouver si la chaîne contient des mots de la liste index” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code