0 votes
88 views
asked in PHP by (4k points)
hi all

   in php how to check word is exits
commented by (4k points)
// Do the check
if (in_array($key, $sent))
{
    echo "Word found";
}
else
{
    echo "Word not found";
}

1 Answer

0 votes
answered by (8.2k points)

 

$needle = "to";
$haystack = "I go to school";

strpos() and stripos() method (stripos() is case insensitive):

if (strpos($haystack, $needle) !== false) echo "Found!";

strstr() and stristr() method (stristr is case insensitive):

if (strstr($haystack, $needle)) echo "Found!";

preg_match method (regular expressions, much more flexible but runs slower):

Categories

...