[英]get values from multidimensional arrays into one table row PHP
I have html table with some data, and one row in that table contain all history about entry description in that row (history data is in seperate db table than main table data). 我有一些数据的html表,并且该表中的一行包含该行中所有条目描述的历史记录(历史记录数据与主表数据位于单独的db表中)。
GROUP_CONCAT(DISTINCT est.id, '|', est.date_estimate ,'|', est.description_estimate SEPARATOR '|') as description_estimate_history
with this DB query I'm getting all entries related to main record. 通过此数据库查询,我得到了与主记录相关的所有条目。
$raw_data = explode("|", $this->reg['rows'][$id]['description_estimate_history']);
$group_data = array_chunk($raw_data, 3);
$this->reg['rows'][$id]['description_joined'] = print_r($group_data);
Array
(
[0] => Array
(
[0] => 105925
[1] => 2013-02-28 02:14:33
[2] => some text
)
[1] => Array
(
[0] => 105958
[1] => 2013-02-28 02:14:33
[2] => some text
)
)
------------------- // other row
Array
(
[0] => Array
(
[0] =>
)
)
----------------- // another row
Array
(
[0] => Array
(
[0] =>
)
)
--------------- //yet another row
Array
(
[0] => Array
(
[0] => 105932
[1] => 2012-12-31 00:00:00
[2] => some text
)
[1] => Array
(
[0] => 105945
[1] => 2012-12-31 00:00:00
[2] => some text
)
)
I can't figure out how to print this data into table rows like date - text
([0] is entry ID) when one row can have multiple records 我无法弄清楚当一行可以有多个记录时,如何将这些数据打印到诸如
date - text
([0]是条目ID)的表格行中
try this snippet to a better understanding on your result array 试试这个代码片段,以更好地了解结果数组
foreach($group_data as $dataArray){ // looping through rows
foreach($dataArray as $array){ // looping through records
foreach($array as $value){ // looping through fields
print $value."<br />";
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.