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";
}
if (strpos($haystack,$needle) !== false) {
echo "$haystack contains $needle";
}
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}