title: How do I preserve this variable through multiple function calls?
body: <p>I have this code:</p>
  
  <pre><code>$k = 0;
      //loop through every question present in query results and run function to present the different question structures
      while ($qs = mysql_fetch_assoc($get_questions))
      {
          $type = $qs['item_type'];
          $item_id = $qs['item_id'];
          $question = $qs['question_text'];
          $question_2 = $qs['question_text_2'];
          present_question($item_id, $type, $question, $question_2, $i, $k);
          $i ++;
          $ids[] = $item_id;
      }
  </code></pre>
  
  <p>now skipping out the switch case in the middle it can end up at this function:</p>
  
  <pre><code>function multi_response($data, $ID, $k){
      $j = 1;     
      while ($answers = mysql_fetch_assoc($data))
          {       
              $as = $answers['text_value'];
              echo "&lt;input name='multi_response[$k][id]' type='hidden' value='$ID'&gt;";
              echo "&lt;strong&gt;".$j.  ".&lt;/strong&gt;&lt;input type='checkbox' name='multi_response[$k][answer]' value='$as'&gt; $as&lt;/br&gt;";
              $k++;
              $j++;
          }       
      return;
  }
  </code></pre>
  
  <p>What I want to do is essentially everytime <code>multi_response()</code> is called, <code>$k</code> is to continuing from where it was last instead of from 0. <code>$k</code> is basically my index value and if it resets to 0 it is overwriting the previous data in the array <code>multi_response[][]</code></p>
  
  <p>I have been trying to return <code>$k</code> to the original loop and parse it back through with no luck.</p>