Php athuga hvort string í band

Kóða dæmi

49
0

php athuga hvort string inniheldur orð

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

php chech ef string inniheldur

$a = 'How are you?';

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

php finna ef hlutstreng er í band

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

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

php finna ef string inniheldur

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

Hvernig á ég að athuga hvort a string inniheldur sérstaka orð?

$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 athuga hvort string inniheldur char

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

Í önnur tungumál

Þetta page er í boði í önnur tungumál

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