// Case-insensitive check without a loop
function charExistsIgnoreCase(string $s, string $target): bool {
// Convert both to lowercase and use str_contains()
return str_contains(strtolower($s), strtolower($target));
}
// Define the string we want to search in
$s = "PHPLanguage";
// Perform the case-insensitive check
$exists = charExistsIgnoreCase($s, 'p');
// Print the raw boolean result
var_export($exists);
echo "\n";
// Conditional check
if ($exists) {
echo "exists\n";
} else {
echo "not exists\n";
}
/*
run:
true
exists
*/