我有一个像这样的多维数组
$input = Array
(
[222] => Array
(
'id' => 222
'val' => 'def'
'more' => 'test'
),
[223] => Array
(
'id' => 223
'val' => 'aaa'
'more' => 'aaa'
),
[224] => Array
(
'id' => 224
'val' => 'aaa'
'more' => 'ddd'
)
[225] => Array
(
'id' => 225
'val' => 'def'
'more' => 'test'
)
);
*重复因为密钥val
和more
的值重复
我想删除重复值(在这种情况下是$ input [222]和$ input [225]。所以结果应该只
$res = Array
(
[222] => Array
(
'id' => 222
'val' => 'def'
'more' => 'test'
),
[223] => Array
(
'id' => 223
'val' => 'aaa'
'more' => 'aaa'
),
[224] => Array
(
'id' => 224
'val' => 'aaa'
'more' => 'ddd'
)
);
任何人都知道怎么做?
感谢
答案 0 :(得分:2)
$newInput = array();
foreach($input as $k => $v) $newInput[$v['val'].$v['more']] = $v;
//You may stop here.
$newInputNum = array();
foreach($newInput as $k => $v) $newInputNum[$v['id']] = $v;
echo "<pre>";print_r($newInputNum );echo "</pre>";