我用array_diff比较了2个通过explode转换成数组的字符串,它可以比较2个相同长度的数组,我如何完成比较不同长度的数组?
前任。
Array1: The quisck browsn fosx
Array2: The quick brown fox
Works!!
Array1: The quisck browsn
Array2: the quick brown fox
doesn't Work!!(狐狸没有提到)
<?php
$str1 = "The quisck browsn";
$str2 = "The quick brown fox";
$tempArr;
$var2;
$ctr=0;
echo "Array1:<br> $str1 <br><br>Array2:<br> $str2";
$strarr = (explode(" ",$str1));
echo("<br>");
$strarr2 = (explode(" ",$str2));
echo("<br>");
$result = array_diff($strarr,$strarr2);
//print_r($result);
if (count($result) > 0){
echo "<br>Differences: | " ;
foreach ($result AS $result){
echo $result." | ";
}
}