PHP Sprawdź, czy ciąg zawiera słowo
$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
echo "My string contains Bob";
}
Grepper
$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
echo "My string contains Bob";
}
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}
$myString = 'Hello Learn Tech Tips (Zidane)?';
if (strpos($myString, 'Zidane') !== false) {
echo "This string contains Zidane";
}
// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}