PHP如何比较两个变量之间的字符串并只显示唯一的字符串?

NOTE: here in the S.O. there are many ways to do this with array keys, between values/words of the same variables, between two different arrays, but I see nothing on the internet between strings and not arrays of two different variables.

<?php
$a = 'this car is very beautiful and is the fast';
$b = 'this red car is very beautiful and is the fast that others';
var_export($unique_words = show_unique_strings($a, $b));
//expected output(painted on the screen): red that others
?>

As Siphalor stated here is an implementation

$a = 'this car is very beautiful and is the fast';
$b = 'this red car is very beautiful and is the fast that others';
echo $unique_words = show_unique_strings($a, $b);
//expected output(painted on the screen): red that others

function show_unique_strings($a, $b) {
  $aArray = explode(" ",$a);
  $bArray = explode(" ",$b);
  $intersect = array_intersect($aArray, $bArray);
  return implode(" ", array_merge(array_diff($aArray, $intersect), array_diff($bArray, $intersect)));
}
<?php
$a = 'this car is very beautiful and is the fast';
$b = 'this red car is very beautiful and is the fast that others';

var_dump(getUniqWords($a, $b));

function getUniqWords($str1, $str2){
    $aWords = explode(" ", $str1);
    $bWords = explode(" ", $str2);
    $results[] = array();

    if(count($aWords) > count($bWords)){
        for($i=0;$i<count($aWords);$i++){
            if(!in_array($aWords[$i], $bWords)){
                array_push($results, $aWords[$i]);
            }
        }
    }else{
        for($i=0;$i<count($bWords);$i++){
            if(!in_array($bWords[$i], $aWords)){
                array_push($results, $bWords[$i]);
            }
        }
    }

    return $results;
}