3

我有 3 个数组,我想将这 3 个数组的结果合二为一,但是如何在数组中删除相同的答案?

这是我的例子:

<?php
$array1 = array("a" => "green", "red", "blue");
$array2 = array("b" => "green", "yellow", "red");
$array3 = array("c" => "white", "blue", "black");
$result = ??? ($array1, $array2, $array3);
print_r($result);
?>

Array
(
    [0] => green
    [1] => red
    [2] => blue
    [3] => yellow
    [4] => red
    [5] => white
    [6] => black
)

请帮帮我。。谢谢。。

4

1 回答 1

7
$result = array_unique(array_merge($array1, $array2, $array3));
于 2012-11-01T11:02:54.947 回答