我有一个如下所示的多维数组,我希望按第一级维度排序,然后在第一级别排序第二级维度。
我希望日期按时间顺序排列,然后在日期内按时间顺序排列。
Array
(
[2014-05-17] => Array
(
[0] => 17:30
[1] => 11:30
[2] => 13:30
[3] => 12:30
[4] => 12:30
)
[2014-06-21] => Array
(
[0] => 17:30
[1] => 10:30
[2] => 13:30
[3] => 09:30
[4] => 12:30
[5] => 09:30
[6] => 12:30
)
[2014-05-18] => Array
(
[0] => 17:30
[1] => 11:30
[2] => 13:30
[3] => 12:30
[4] => 12:30
)
)
此外,在我对时间进行排序后,我想删除重复项 - 换句话说,我只是希望每个日期中的唯一时间按时钟顺序排列。
以下是我想要制作的内容:
[2014-05-17] =>排列 ( [0] => 11:30 [1] => 12:30 [2] => 13:30 [3] => 17:30 )
[2014-05-18] =>排列 ( [0] => 11:30 [1] => 12:30 [2] => 13:30 [3] => 17:30 )
[2014-06-21] =>排列 ( [0] => 09:30 [1] => 10:30 [2] => 12:30 [3] => 13:30 [4] => 17:30 )
答案 0 :(得分:1)
如果您的变量数组名称是$ arrayDate,请执行以下命令:
ksort($arrayDate);
foreach($arrayDate as &$key){
$key = array_unique($key);
sort($key);
}