php 2 D配列の重み付けの簡単な処理

530 ワード

$new = array();
$arr = array(
   array(
       'id'=>'221',
       'key'=>'  '
   ),
    array(
        'id'=>'221',
        'key'=>'  '
    ),
    array(
        'id'=>'222',
        'key'=>'   '
    )
);
foreach ($arr as $key=>$v) {
    if(isset($new[$v['id']]) == false){
        $new[$v['id']] = $v;
    }
}
echo "
";
var_dump($new);die;