How to check whether a string contains a specific word in PHP

1 Answer

0 votes
$str = 'c php c# c++ java python';

$word = 'php';

if (strpos($str, $word) !== false) {
    echo 'Found';
} else {
    echo 'Not found';
}
 
 
 
 
 
/*
run:
 
Found
 
*/

 



answered Jun 16, 2021 by avibootz
...