我有两个数组如下:
包含项目结构的给定任务的工作时间。以及如下信息, [projectname] - 项目名称
[structurename] - 结构名称(项目有很多结构)
[taskname] - 任务名称(结构有很多任务)
[taskstartdate] - 任务的开始日期
[估计小时] - 估计任务的小时数
[小时] - 员工处理任务的小时数
[createdon] - 员工工作小时数的日期
Array ( [0] => stdClass Object ( [projectname] => test p1 [structurename] => test structure [taskname] => task [taskstartdate] => 2016-02-02 00:00:00 [estimatedhours] => 10.00 [hours] => 5.00 [createdon] => 2016-02-03 07:38:08 )
[1] => stdClass Object ( [projectname] => test p1 [structurename] => test structure [taskname] => task [taskstartdate] => 2016-02-02 00:00:00 [estimatedhours] => 10.00 [hours] => 2.00 [createdon] => 2016-02-04 14:21:34 )
[2] => stdClass Object ( [projectname] => p2 [structurename] => struc [taskname] => p2t1 [taskstartdate] => 2016-02-03 00:00:00 [estimatedhours] => 8.00 [hours] => 2.00 [createdon] => 2016-02-04 11:05:31 )
[3] => stdClass Object ( [projectname] => p2 [structurename] => struc [taskname] => p2t1 [taskstartdate] => 2016-02-03 00:00:00 [estimatedhours] => 8.00 [hours] => 6.00 [createdon] => 2016-02-05 08:00:22 )
[4] => stdClass Object ( [projectname] => web dev [structurename] => dev test [taskname] => dev task [taskstartdate] => 2016-02-04 00:00:00 [estimatedhours] => 30.00 [hours] => 8.00 [createdon] => 2016-02-04 08:21:14 ))
第二个数组包含给定周的天数(在本例中为2016年第一周,2月)
Array ( [0] => 2016-02-01
[1] => 2016-02-02
[2] => 2016-02-03
[3] => 2016-02-04
[4] => 2016-02-05 )
使用上述两个数组我想创建一个单个数组对象,如下所示, 这背后的想法是为一个项目创建一行数组,并为给定的05天添加工作小时数。预期数组的描述如下,
[name] - [projectname] |的组合[structurename] |第一个数组的[taskname]
[taskstartdate] - 第一个数组的任务开始日期
[估计小时] - 从第一个阵列估计的小时数
[01] - 从2016-02-01获取01并从第二个数组
添加为键[02] - 从2016-02-02获得02并从第二个数组
添加为关键字[03] => 5.00 - 从2016-02-03获得03并从第二个阵列添加为关键字 并且还添加5.00作为值。
这是因为第一个数组[hours] => 5.00 [createdon] => 2016-02-03 07:38:08这意味着一名员工在2016-02-03工作了5个小时,所以应该将其作为价值添加。
[04] => 2.00 - 根据[1] => stdClass第一个数组员工的对象在2016-02-04
上工作了同一个项目2.00小时 Array ( [0] => stdClass Object ( [name] => test p1 | test structure | task [taskstartdate] => 2016-02-02 00:00:00 [estimatedhours] => 10.00 [01] => 0 [02] => 0 [03] => 5.00 [04] => 2.00 [05] => 0)
[1] => stdClass Object ( [name] => p2 | struc | p2t1 [taskstartdate] => 2016-02-03 00:00:00 [estimatedhours] => 8.00 [01] => 0 [02] => 0 [03] => 0 [04] => 2.00 [05] => 6.00 )
[2] => stdClass Object ( [name] => web dev | dev test | dev task [taskstartdate] => 2016-02-04 00:00:00 [estimatedhours] => 30.00 [01] => 0 [02] => 0 [03] => 0 [04] => 8.00 [05] => 6.00)
我希望您能理解逻辑,如果需要更多信息,请发表评论。
这超出了我的理解,所以我没有为此尝试代码。
最好的问候。