我想比较两个数组之间整行的数据并生成:
- 相交行的数组和
- 一个数组,其中第一个数组中的行在第二个数组中找不到,并且
- 一个数组,其中在第一个数组中找不到第二个数组中的行。
我有两个多维数组。
$array1 = [
['sight_id' => 13, 'location' => 'Jodhpur, Rajasthan, India'],
['sight_id' => 14, 'location' => 'Jodhpur Jn, Jodhpur, Rajasthan, India'],
['sight_id' => 15, 'location' => 'D-Kirtinagar, Jodhpur, Rajasthan, India'],
];
$array2 = [
['sight_id' => 13, 'location' => 'Jodhpur, Rajasthan, India'],
['sight_id' => 14, 'location' => 'Jodhpur Jn, Jodhpur, Rajasthan, India'],
['sight_id' => 16, 'location' => 'Jaisalmer, Rajasthan, India'],
['sight_id' => 17, 'location' => 'Fort Road, Amar Sagar Pol, Jaisalmer, Rajasthan, India'],
];
期望的结果:
$intersect_array = [
['sight_id' => 13, 'location' => 'Jodhpur, Rajasthan, India'],
['sight_id' => 14, 'location' => 'Jodhpur Jn, Jodhpur, Rajasthan, India'],
and
$only_a1 = [
['sight_id' => 15, 'location' => 'D-Kirtinagar, Jodhpur, Rajasthan, India'],
]
and
$only_a2 = [
['sight_id' => 16, 'location' => 'Jaisalmer, Rajasthan, India'],
['sight_id' => 17, 'location' => 'Fort Road, Amar Sagar Pol, Jaisalmer, Rajasthan, India'],
];