PHP关联数组交集返回两个元素而不是一个元素

I have two associative arrays as following

    Array
(

    [0] => Array
        (
            [description] => aaaaaa
            [value] => 11111
            [id] => 14
        )

    [1] => Array
        (
            [description] => dddddd
            [value] => 44444
            [id] => 0
        )

)




Array
(

    [0] => Array
        (
            [id] => 14
            [value] => 11111
            [description] => aaaaaa
        )

    [1] => Array
        (
            [id] => 15
            [value] => 222222
            [description] => bbbbbb
        )

    [2] => Array
        (
            [id] => 16
            [value] => 333333
            [description] => cccccc
        )

)

The result I am getting is

Array
(

    [0] => Array
        (
            [description] => aaaaaa
            [value] => 11111
            [id] => 14
        )

    [1] => Array
        (
            [description] => dddddd
            [value] => 44444
            [id] => 0
        )

)

Noting that dddd is available in the first array but not the second.

I am using the array_intersect_assoc( $array1, $array2 ) function. Please help. It's not logical at all to return such results

Use below code

$intersect = array_uintersect($arr1, $arr2, 'compareDeepValue');
 print_r($intersect);

 function compareDeepValue($val1, $val2)
 {
  return strcmp($val1['value'], $val2['value']);
 }

If you will enable php notices you will see next

Notice: Array to string conversion

You can get exhaustive answer about your problem here

Good luck!