Veronica 99
Veronica 99

Reputation: 23

How to find the difference between two multidimentional array

I have an array in the form like

Array
(
    [83YaO] => Array
        (
            [0] => [email protected]
        )
    [78hk0] => Array
        (
            [0] => [email protected]
        )

)

and another array in the form

Array
(
    [83YaO] => Array
        (
            [0] => [email protected]
            [1] => [email protected]
            [2] => [email protected]
        )
)

How can I find differences to add a contact like

Array
(
    [83YaO] => Array
        (
            [0] => [email protected]
            [1] => [email protected]
        )
    [78hk0] => Array
        (
            [0] => [email protected]
        )
)

and to rejected a contact like this:

[83YaO] => Array
    (
        [0] => [email protected]
    )

Upvotes: 0

Views: 58

Answers (1)

user1805543
user1805543

Reputation:

Compares array1 against array2 or more other arrays and returns the values in array1 that are not present in any of the other arrays.

$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");


$result = array_diff($array1, $array2);

print_r($result);

Upvotes: 1

Related Questions