How to find the words in string that exist in another string with PHP

1 Answer

0 votes
$s = "How to extract all digits from string in PHP Collective Solver";
$search = "CollectiveSolver";

$arr = explode(" ", $s);

foreach ($arr as $word) {
  if (strpos($search, $word) !== false)
      echo $word . "\n";
}



/*
run:

Collective
Solver

*/

 



answered Dec 19, 2020 by avibootz
edited Dec 19, 2020 by avibootz
...