$array = array(
'1'=>array('title'=>'1111','date'=>'2222'),
'2'=>array('title'=>'1111','date'=>'5555'),
'3'=>array('title'=>'4444','date'=>'3333')
);
想用写一个函数,传入数组, 删除含有重复的值,
例 $array['2'] 的 'title' => '1111' 在 $array['1']中也有,删除$array['2'], $array['3']为$array['2']
$array = array('1'=>array('title'=>'1111','date'=>'2222'),'2'=>array('title'=>'1111','date'=>'5555'),'3'=>array('title'=>'4444','date'=>'3333'));$tmp = array();foreach($array as $v) if(!isset($tmp[$v['title']])) $tmp[$v['title']] = $v;$array = array_values($tmp);print_r($array);
Array( [0] => Array ( [title] => 1111 [date] => 2222 ) [1] => Array ( [title] => 4444 [date] => 3333 ))
$array = array('1'=>array('title'=>'1111','date'=>'2222'),'2'=>array('title'=>'1111','date'=>'5555'),'3'=>array('title'=>'4444','date'=>'3333'));$tmp = array();foreach($array as $v) if(!isset($tmp[$v['title']])) $tmp[$v['title']] = $v;$array = array_values($tmp);print_r($array);
Array( [0] => Array ( [title] => 1111 [date] => 2222 ) [1] => Array ( [title] => 4444 [date] => 3333 ))