mick Smarty n00b
Joined: 11 Sep 2015 Posts: 1
|
Posted: Fri Sep 11, 2015 1:35 am Post subject: Smarty HTML Table with a multi-dimensional array? |
|
|
I've got an array with three arrays within it. These sub arrays are different length but in terms of comparisons in my table the start the same always.
I'm trying to have 3 columns for each array and list the array values under the referring column. However I'm mixed up in creating the table.
Below's attempt only gives me one row with 10 columns. First column is blank, then the first three entries for each inner array but then stops. I'd like to get rid of the blank column too.
Code: |
<table id="t01">
<tr>
<th>Blank</th>
{foreach from=$numFlocks item=foo}
<th>Flock {$foo}</th>
{/foreach}
</tr>
<tr>
{foreach from=$numFlocks item=columns}
{section loop={$flock[$columns]} name=unit}
<td>{$flock[unit]}</td>
{/section}
{/foreach}
</tr>
</table>
|
var_export from PHP shows my array as:
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', ), )[/img][/code] |
|