如何才能获得只有不同密钥的输出数组?

问题描述:

I have following two array

$array1 = array("product_a" => "Nokia1", "product_b" => "Nokia11", "product_c" => "Nokia111", "Nokia1111");
$array2 = array("product_a" => "Nokia1", "Samsung", "Nokia1111");

I want to compare these both array and want output as having different keys

Like my output as below

Array
(
    [product_b] => Nokia11
    [product_c] => Nokia111
    [0] => Nokia1111
)

is there any default php method available to compare?

</div>

I think that you can try

function key_compare_func($a, $b)
{
    if ($a === $b) {
        return 0;
    }
    return ($a > $b)? 1:-1;
}

You can get some reference with following link too,

http://questionnanswer.com/questions/view_question/80/category_list:2/how-can-get-different-key-array?

</div>