比较两个字符串并在php中返回不同的值
当比较$a和$b时,它将返回一个数组$arr={goes,comes}来自与$a不同的$b。请建议一个解决方案尝试使用PHP函数比较两个字符串并在php中返回不同的值,php,string,Php,String,当比较$a和$b时,它将返回一个数组$arr={goes,comes}来自与$a不同的$b。请建议一个解决方案尝试使用PHP函数 $a = "what go around, come around"; $b = "what goes around, comes around"; 它将array1与一个或多个其他数组进行比较,并返回array1中不存在于任何其他数组中的值。只需使用preg_split和array_diff,如 输出: 你想完成什么?$arr=array\u diffstr\u
$a = "what go around, come around";
$b = "what goes around, comes around";
它将array1与一个或多个其他数组进行比较,并返回array1中不存在于任何其他数组中的值。只需使用preg_split和array_diff,如
输出:
你想完成什么?$arr=array\u diffstr\u word\u count$b,2,str\u word\u count$a,2;可能重复@MarkBaker这是一个很好的答案,请将其作为答案发布+1.
array array_diff ( array $array1 , array $array2 [, array $... ] )
$a = "what go around, come around";
$b = "what goes around, comes around";
echo implode(',',array_diff(preg_split('/\h/',$b),preg_split('/\h/',$a)));
goes,comes