如何从嵌套数组中生成表格数据
您好,我正在处理出勤报告,我们有数组中的数据:
Array
(
[0] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:09:02
[eventID] => OUT
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[1] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:09:12
[eventID] => IN
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[2] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:11:31
[eventID] => OUT
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[3] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:11:40
[eventID] => IN
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[4] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:13:17
[eventID] => OUT
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[5] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:13:21
[eventID] => IN
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
)
报告格式是:
Date In Time Out Time Work Time
2011-02-16
我需要帮助显示同一天的一行中的时间和外出时间。
请帮忙
Hi iam working on attendance report, data in array we have :
Array
(
[0] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:09:02
[eventID] => OUT
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[1] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:09:12
[eventID] => IN
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[2] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:11:31
[eventID] => OUT
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[3] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:11:40
[eventID] => IN
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[4] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:13:17
[eventID] => OUT
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
[5] => Array
(
[ActatekLog] => Array
(
[id] => 1
[timeentry] => 2011-02-16 00:13:21
[eventID] => IN
[terminalSN] => 00111DA08C8B
[jpegPhoto] =>
)
)
)
report format is :
Date In Time Out Time Work Time
2011-02-16
i need help in display in time and out time in one row for same day.
Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我首先会稍微格式化输出数组。
那么输出应该更容易一些:
I would start by formatting the output array a little bit first.
Then output should be a little easier:
我使用的数据模型永远不会改变,并且您的数据已经按照您希望的方式进行排序。因此,对于这样的数组:
我创建了一个函数,它返回一个包含 n/2 行的数组,并且 IN 和 OUT 位于同一行。
I'm using your data model never changes and that your data is already sorted the way you'd like it to be sorted. So, for an array like this:
I made a function, that returns an array with n/2 rows and has both IN and OUT in the same row.
尽管数组中没有您在表中声明的两个值,但您可以做到这一点。
Here you go that'll do it though you dont have two values in your array that you state you want in your table.