Php vérifie si la chaîne dans la chaîne

Exemples de code

49
0

php vérifie si la chaîne contient un mot

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

php chech si la chaîne contient

$a = 'How are you?';

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

php trouve si la sous-chaîne est dans une chaîne

$result = strpos("haystack", "needle");

if ($result != false)
{
  // text found
}
4
0

php trouve si la chaîne contient

if (strpos($string, 'substring') !== false) {
	// do stuff 
}
2
0

Comment vérifier si une chaîne contient un mot spécifique?

$a = 'Hello world?';

if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
    echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
    echo 'true';
}
1
0

php vérifie si la chaîne contient un caractère

$haystack = 'This is my haystack that we shall check'
$has_A = strpos($haystack, 'A') !== false;
$has_a = strpos($haystack, 'a') !== false;

Dans d'autres langues

Cette page est dans d'autres langues

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................