"1","time"=>"5","neirong"=>"www");$aa=array("id"=>"2","time"=>"55","neirong"=>"www");$aa=array">
时间:2021-07-01 10:21:17 帮助过:4人阅读
$aa = array(
array("id"=>"1","time"=>"5","neirong"=>"www"),
array("id"=>"2","time"=>"55","neirong"=>"www"),
array("id"=>"4","time"=>"555","neirong"=>"www"),
array("id"=>"5","time"=>"555","neirong"=>"www"),
);
$bb = array(
array("id"=>"1","time"=>"5"),
array("id"=>"2","time"=>"50"),
array("id"=>"3","time"=>"555"),
);
foreach($aa as $v) $r[$v['id']] = $v;
foreach($bb as $v) {
$k = $v['id'];
if(! isset($r[$k])) $r[$k] = $v;
elseif($r[$k]['time'] < $v['time']) $r[$k] = $v;
elseif($r[$k]['time'] == $v['time']) unset($r[$k]);
}
ksort($r);
print_r($r);
Array
(
[2] => Array
(
[id] => 2
[time] => 55
[neirong] => www
)
[3] => Array
(
[id] => 3
[time] => 555
)
[4] => Array
(
[id] => 4
[time] => 555
[neirong] => www
)
[5] => Array
(
[id] => 5
[time] => 555
[neirong] => www
)
)