Php匹配两个数组之间的值,但元素类似敌人


Php match values between 2 arrays but foe like elements

我知道php中有array_intersect,但我希望在两个数组中显示类似的元素。例如:

array1 = [product, php]
array2 = [product management, html]

我希望得到的数组显示result = [product managemenet]array_incross将在此处给出空结果。

$result=array();
$array1 = array('product','php');
$array2 = array('product management','html');
$srcharray = $array2;
foreach($array1 as $serchstr)
{
  foreach($srcharray as $key => $serchval)
  {
     if (strpos($serchval, $serchstr) !== false) {
     $result[] = $serchval;
     unset($srcharray[$key]);
     }
  } 
}
var_dump($result);

注意:如果需要区分大小写的匹配。。使用"stripos"而不是"strpos"。