Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty HTML Table with a multi-dimensional array?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
mick
Smarty n00b


Joined: 11 Sep 2015
Posts: 1

PostPosted: Fri Sep 11, 2015 1:35 am    Post subject: Smarty HTML Table with a multi-dimensional array? Reply with quote

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]
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP