我的数据结构如下所示
Array
(
[0] => Array
(
[name] => dummy0
[projects] => Array
(
[project_names] => project0
[dates] => Array
(
[0] => 5
[1] => 11
[2] => 28
)
)
)
[1] => Array
(
[name] => dummy1
[projects] => Array
(
[project_names] => project1
[dates] => Array
(
[0] => 10
[1] => 12
[2] => 28
)
)
)
)
我希望得到以下格式的输出
dummy0
Project0 5 11 28
dummy1
Project1 10 12 28
我在下面的代码片段中使用了但是在我除外的情况下没有得到oupput
[replies;block=begin;sub1=projects]
[replies_sub1.val;block=tr;sub1=dates]
[replies_sub1_sub1.val;block=td]
[replies;block=end;comm=text:p]
任何形式的帮助将不胜感激
答案 0 :(得分:0)
问题是您的子数据dates
实际上属于2个级别的列:项目/日期。并且TBS不支持自动子块的这种数据结构。
解决方案是更改您的数据结构,以便像这样:
(
[0] => Array
(
[name] => dummy0
[dates] => Array
(
[0] => 5
[1] => 11
[2] => 28
)
....
)
....
如果您无法更改结构,只需使用参数ondata
和自定义函数即可在数据中创建新的(虚拟)列。
PHP:
function f_ondata($BlockName,&$CurrRec,$RecNum) {
$CurrRec['dates_z'] = $CurrRec['projects']['dates'];
}
HTML:
<div style="border: solid 1px red;">
[replies;block=begin;sub1=dates_z;ondata=f_ondata]
<table border="1">
<tr>
<td>
[replies.projects.project_names]
</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
[replies_sub1.val;block=tr]
</td>
</tr>
</table>
<text:p> [replies;block=end;comm=text:p] </text:p>
<div>