“PHP encuentra la subcadena” Código de respuesta

PHP encuentra la subcadena

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

STPO en PHP


<?php
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);

// Note our use of ===.  Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
    echo "The string '$findme' was not found in the string '$mystring'";
} else {
    echo "The string '$findme' was found in the string '$mystring'";
    echo " and exists at position $pos";
}
?>

Kaotik

Php Needle Haystack

//Find the position of the first occurrence of a substring in a string
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
Cannibal Capybara

la cadena PHP contiene

$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
gtamborero

STPO PHP


<?php
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);

// El operador !== también puede ser usado. Puesto que != no funcionará como se espera
// porque la posición de 'a' es 0. La declaración (0 != false) se evalúa a 
// false.
if ($pos !== false) {
     echo "La cadena '$findme' fue encontrada en la cadena '$mystring'";
         echo " y existe en la posición $pos";
} else {
     echo "La cadena '$findme' no fue encontrada en la cadena '$mystring'";
}
?>

Famous Ferret

Respuestas similares a “PHP encuentra la subcadena”

Preguntas similares a “PHP encuentra la subcadena”

Más respuestas relacionadas con “PHP encuentra la subcadena” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código