xxxxxxxxxx
$string = "Hello123";
$containsLetters = preg_match("/[a-z]/i", $string);
if ($containsLetters) {
echo "The string contains letters.";
} else {
echo "The string does not contain any letters.";
}
xxxxxxxxxx
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}
xxxxxxxxxx
phpCopy<?php
$mystring = "This is a PHP program.";
if (strpos($mystring, "program.") !== false) {
echo("True");
}
?>
xxxxxxxxxx
$string = "Hello World";
$substring = "World";
if (strpos($string, $substring) !== false) {
echo "The string contains the substring";
} else {
echo "The string does not contain the substring";
}
xxxxxxxxxx
phpCopy<?php
$mystring = "This is a php program.";
$search = "a";
if(preg_match("/{$search}/i", $mystring)) {
echo "True"; } else {
echo("False");
}
?>
xxxxxxxxxx
phpCopy<?php
$mystring = "This is a PHP program.";
if (strpos($mystring, "PHP", 13) !== false) {
echo("True");
} else {
echo("False");
}
?>