如何从使用 SMARTY 显示的 PHP 中提取的数组中删除第一条数据?
How to remove the first piece of data from an array extracted from PHP, displayed with SMARTY?
我正在尝试使用 SMARTY 将下面的数组显示为 HTML table。一切都很完美,但是 table 的第一行显示为:
阵列阵列阵列
然后数据在这之后就如愿以偿了。显然我不想显示以上内容。
下面是从 PHP 文件导出的数组:该数组由三个数组组成,因此是三列。
array ( 0 => array ( ), 1 => array ( 0 => array ( ), 1 => '2160', 2 => '63800', 3 => '175820', 4 => '234823', 5 => '253080', 6 => '256680', 7 => '258760', 8 => '258840', 9 => '259560', 10 => '258480', 11 => '258550', 12 => '258660', 13 => '258480', 14 => '258300', 15 => '256140', 16 => '257770', 17 => '255960', 18 => '255780', 19 => '252520', 20 => '253980', 21 => '252540', 22 => '250560', 23 => '245700', 24 => '253080', 25 => '248580', 26 => '248860', 27 => '249660', 28 => '246780', ), 2 => array ( 0 => array ( ), 1 => '2150', 2 => '63800', 3 => '175420', 4 => '234843', 5 => '253080', ), 3 => array ( 0 => array ( ), 1 => '2110', 2 => '63800', 3 => '175820', 4 => '234823', 5 => '252180', 6 => '256680', ), )
下面是我如何显示当前 table:
<table id="t01">
<tr>
<th>Blank</th>
{foreach from=$numFlocks item=foo}
<th>Flock {$foo}</th>
{/foreach}
</tr>
{section loop=$flock[1] name=unit}
<tr>
{foreach from=$flock item=foo}
<td>{$foo[unit]}</td>
{/foreach}
</tr>
{/section}
</table>
无需显示第一行。
{section loop=$flock[1] name=unit}
<tr {if $smarty.section.unit.first}style="display:none"{/if}>
{foreach from=$flock item=foo}
<td>{$foo[unit]}</td>
{/foreach}
</tr>
{/section}
我正在尝试使用 SMARTY 将下面的数组显示为 HTML table。一切都很完美,但是 table 的第一行显示为:
阵列阵列阵列
然后数据在这之后就如愿以偿了。显然我不想显示以上内容。
下面是从 PHP 文件导出的数组:该数组由三个数组组成,因此是三列。
array ( 0 => array ( ), 1 => array ( 0 => array ( ), 1 => '2160', 2 => '63800', 3 => '175820', 4 => '234823', 5 => '253080', 6 => '256680', 7 => '258760', 8 => '258840', 9 => '259560', 10 => '258480', 11 => '258550', 12 => '258660', 13 => '258480', 14 => '258300', 15 => '256140', 16 => '257770', 17 => '255960', 18 => '255780', 19 => '252520', 20 => '253980', 21 => '252540', 22 => '250560', 23 => '245700', 24 => '253080', 25 => '248580', 26 => '248860', 27 => '249660', 28 => '246780', ), 2 => array ( 0 => array ( ), 1 => '2150', 2 => '63800', 3 => '175420', 4 => '234843', 5 => '253080', ), 3 => array ( 0 => array ( ), 1 => '2110', 2 => '63800', 3 => '175820', 4 => '234823', 5 => '252180', 6 => '256680', ), )
下面是我如何显示当前 table:
<table id="t01">
<tr>
<th>Blank</th>
{foreach from=$numFlocks item=foo}
<th>Flock {$foo}</th>
{/foreach}
</tr>
{section loop=$flock[1] name=unit}
<tr>
{foreach from=$flock item=foo}
<td>{$foo[unit]}</td>
{/foreach}
</tr>
{/section}
</table>
无需显示第一行。
{section loop=$flock[1] name=unit}
<tr {if $smarty.section.unit.first}style="display:none"{/if}>
{foreach from=$flock item=foo}
<td>{$foo[unit]}</td>
{/foreach}
</tr>
{/section}