Search code examples
phpstrpos

PHP strpos not working right


EDIT:

Ok for everyone who seems to be mentally disabled or something, check this out how it should be and why Halcyon's solution to swap haystack and needle DO MAKE SENSE:

$test = 'bla';
if(strpos($test, 'hauptkat') !== false OR strpos($test, 'kat') !== false)
{
    echo 'hauptkat or kat is inside $test';
}
else
{
    echo 'hauptkat or kat is NOT inside $test';
}

Solution

  • I think you've swapped your needle and haystack.

    strpos("hauptkat", "kat") // 5
    

    See: strpos.