“php trouver la sous-chaîne” Réponses codées

php trouver la sous-chaîne

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

strPos 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

back de foin d'aiguille php

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

La chaîne PHP contient

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

strPos 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

Réponses similaires à “php trouver la sous-chaîne”

Questions similaires à “php trouver la sous-chaîne”

Plus de réponses similaires à “php trouver la sous-chaîne” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code