简体   繁体   中英

How to find the difference between two multidimentional array

I have an array in the form like

Array
(
    [83YaO] => Array
        (
            [0] => admin@gmail.com
        )
    [78hk0] => Array
        (
            [0] => vero@gmail.com
        )

)

and another array in the form

Array
(
    [83YaO] => Array
        (
            [0] => admin@gmail.com
            [1] => asdsad@gmail.com
            [2] => singh@gmail.com
        )
)

How can I find differences to add a contact like

Array
(
    [83YaO] => Array
        (
            [0] => admin@gmail.com
            [1] => singh.pratibha1432@gmail.com
        )
    [78hk0] => Array
        (
            [0] => vero@gmail.com
        )
)

and to rejected a contact like this:

[83YaO] => Array
    (
        [0] => admin@gmail.com
    )

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM