-4

I have these arrays $arr1 and $arr2

$arr1 = array(
                    'tn' => 'Tunisia',
                    'us' => 'United States',
                    'fr' => 'France');

$arr2 = array(
                    'tn' => 'Tunisia',
                    'us' => 'United States',
                    'fr' => 'France',
                    'mx' => 'Mexico',
                    'eu' => 'Europe' );

I want to compare $arr1 with $arr2 and if the keys in $arr2 does not exist in $arr1, the keys should be deleted from $arr2. and the resulting array of $arr3 should be same as $arr1.

$arr3 = array(
                    'tn' => 'Tunisia',
                    'us' => 'United States',
                    'fr' => 'France');
4

1 回答 1

1

尝试这个

 $arr3 = array_intersect($arr1, $arr2);

阅读此网址一次

可能是它的帮助充分

于 2013-07-26T13:09:35.973 回答