title: Load a 2D array on smarty html pages
body: <p>I'm trying to develop a Question&amp;Answer website in php using Smarty framework. So far it is going smooth but I started to develop the comments part and I'm not getting how I can implement it. </p>
  
  <ul>
  <li>Question
  
  <ul>
  <li>Answer 1
  
  <ul>
  <li>Comment 1</li>
  <li>Comment 2</li>
  <li>Comment 3</li>
  </ul></li>
  <li>Answer 2
  
  <ul>
  <li>Comment 1</li>
  <li>Comment 2</li>
  <li>Comment 3</li>
  </ul></li>
  <li>Answer 3
  
  <ul>
  <li>Comment 1</li>
  <li>Comment 2</li>
  <li>Comment 3</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>This is my question structure. The answers part is pretty easy because it does not matter how I print it, I just need to get all the answers from a given questionid and show it in the question page. But when it comes to comments, it is different. 
  How can I show the answers comments correctly? Do I need to create a 2D array where I have an array with answers and their comments? </p>
  
  <pre><code>&lt;?php
  include_once('../../../config/init.php');
  include_once($BASE_DIR . 'database/questions.php');
  
  increment_views_counter((int) $_GET['question']);
  
  if($_SESSION['logged_in']) {
      $smarty-&gt;display('common/header_log.tpl');
  } else {
      $smarty-&gt;display('common/narrow_header.tpl');
  }
  
  $questions = get_questions_from_id($_GET['question']);
  $tags = get_tags_from_question($_GET['question']);
  $question = $questions[0];
  $question['isMine'] = question_is_mine($question);
  $answers = get_answers_from_questionid($_GET['question']);
  
  $smarty-&gt;assign('isMine', $question['isMine']);
  $smarty-&gt;assign('tags', $tags);
  $smarty-&gt;assign('answers', $answers);
  $smarty-&gt;assign('question', $question);
  $smarty-&gt;display('question.tpl');
  $smarty-&gt;display('common/footer.tpl');
  </code></pre>
  
  <p>This is my pages/question.php . I get the question info I need, including the answers. Now, I need to get the comments for each answer and a way to show them on my template:</p>
  
  <pre><code>&lt;div class="qa-a-list-item hentry answer"&gt;
                                              {foreach $answers as $answer}
                                                  {include file="answers.tpl"}
                                              {/foreach}
                                              &lt;!-- END qa-a-item-main --&gt;
                                          &lt;/div&gt;
  </code></pre>
  
  <p>And then I'd need to loop each answer and print all the comments. How and when should I load them? Should I gather all the comments when I load the question page?</p>
  
  <p>Kind regards</p>