-1

我有两个数组:

数组1:

Array ( [id] => 1 [time] => 12:10:23 [date] => 2013-03-24 )

数组2:

Array ( [id] => 2 [time] => 12:10:25 [date] => 2013-03-25 )

我想合并它们,以便它们产生以下结果(已编辑):

Array ( [id] => 1
             => 2
        [time] => 12:10:23
               => 12:10:25
        [date] => 2013-03-24 
               => 2013-03-25 
      )

这可能吗?

4

1 回答 1

2

如果你真的想要输出:

Array (
    Array ([id] => 1 [time] => 12:10:23 [date] => 2013-03-24 ),
    Array ([id] => 2 [time] => 12:10:25 [date] => 2013-03-25 )
)

然后你想使用下面的代码:

$newArray = array($array1, $array2);

要获取最近日期的元素:

$most_recent = $newArray[0];
foreach($newArray as $compare)
{
    if($compare['time'] > $most_recent['time'])
    {
        $most_recent = $compare;
    }
}
于 2013-03-25T05:14:14.990 回答