php sprawdź czy string zawiera słowo
$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
echo "My string contains Bob";
}
php chech if string contains
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}
PHP find if substring is in string
$result = strpos("haystack", "needle");
if ($result != false)
{
// text found
}
PHP find if string contains
if (strpos($string, 'substring') !== false) {
// do stuff
}
Jak sprawdzić, czy ciąg zawiera konkretne słowo?
$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}
php sprawdza czy string zawiera znak
$haystack = 'This is my haystack that we shall check'
$has_A = strpos($haystack, 'A') !== false;
$has_a = strpos($haystack, 'a') !== false;