📜  php 计算两个字符串中匹配的单词 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:41.880000             🧑  作者: Mango

代码示例1
$string1 = 'The dog and cat love each other';
$string2 = 'the dog pooped in the yard';
$arr1 = explode(" ",$string1 );
$arr2 = explode(" ",$string2 );
$result = array_intersect($arr1 , $arr2 ); //matched elements
$num = count($result); //number of matches