PHP 比较两个数组,得到匹配的值,而不是差值
我试图比较两个数组,只得到两个数组上存在的值,但不幸的是,我找不到正确的数组函数来使用...
我找到了功能:http://php.net/manual/en/function.array-diff.phparray_diff()
但这是为了两个数组的差异。
例:
$array1 = array("**alpha**","omega","**bravo**","**charlie**","**delta**","**foxfrot**");
$array2 = array("**alpha**","gamma","**bravo**","x-ray","**charlie**","**delta**","halo","eagle","**foxfrot**");
预期输出:
$result = array("**alpha**","**bravo**","**charlie**","**delta**","**foxfrot**");