“Php Buscar si la cadena contiene palabras del índice de lista” Código de respuesta

Php verifique si la cadena contiene palabras de matriz

$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 Buscar si la cadena contiene palabras del índice de lista

$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

Respuestas similares a “Php Buscar si la cadena contiene palabras del índice de lista”

Preguntas similares a “Php Buscar si la cadena contiene palabras del índice de lista”

Más respuestas relacionadas con “Php Buscar si la cadena contiene palabras del índice de lista” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código