假设我有一个数组,其中所有内容均按TemplateID值排序:
Array
(
[Template 1] => Array
(
[0] => Array
(
[CustomerID] => 1
[TemplateID] => Template 1
[ScheduledTime] => 2019-08-30 10:01:00
)
[1] => Array
(
[CustomerID] => 2
[TemplateID] => Template 1
[ScheduledTime] => 2019-08-30 10:02:00
)
[2] => Array
(
[CustomerID] => 3
[TemplateID] => Template 1
[ScheduledTime] => 2019-08-30 10:03:00
)
)
[Template2] => Array
(
[3] => Array
(
[CustomerID] => 4
[TemplateID] => Template2
[ScheduledTime] => 2019-07-30 10:02:00
)
)
)
如何修改数组,以便ScheduledTime的所有唯一值都是每个TemplateID的子元素?
我实质上是在尝试为所有具有相同TemplateID但具有不同ScheduledTime的组创建一个组:
Array
(
[Template 1] => Array (
[2019-08-30 10:01:00] => Array (
[0] => Array (
[CustomerID] => 1
[TemplateID] => Template 1
[ScheduledTime] => 2019-08-30 10:01:00
)
[1] => Array (
[CustomerID] => 2
[TemplateID] => Template 1
[ScheduledTime] => 2019-08-30 10:01:00
)
)
[2019-08-30 10:03:00] => Array (
[0] => Array (
[CustomerID] => 3
[TemplateID] => Template 1
[ScheduledTime] => 2019-08-30 10:03:00
)
)
)
[Template2] => Array (
[2019-07-30 10:02:00] => Array (
[0] => Array (
[CustomerID] => 4
[TemplateID] => Template2
[ScheduledTime] => 2019-07-30 10:02:00
)
)
)
)
答案 0 :(得分:-1)