php string contains

126

php string contains -

$string = 'The lazy fox jumped over the fence';

if (str_contains($string, 'lazy')) {
    echo "The string 'lazy' was found in the string\n";
}

php chech if string contains -

$a = 'How are you?';

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

string contains php -

$a = 'How are you?';

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

php if string contains -

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

php string contains -

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

Comments

Submit
0 Comments