title: How to add variables that are passed on through the URL to an array?
body: <pre><code>&lt;?php
  $i = $_GET['i'];
  echo $i;
  $values = array();
  
  while ($i &gt; 0)
  {
  
  $expense = $_GET['expense_' + i];
  $amount = $_GET['amount_' + i];
  
  $values[$expense] = $amount;
  i--;
  
  print_r($values);
  
  }
  ?&gt;
  </code></pre>
  
  <p>i represents the number of sets of variables I have that have been passed through from the previous page. What I'm trying to do is add the expenses to the amounts and put them in an array as (lets just say for this example there were 3 expenses and 3 amounts) [expense_3 => amount_3, expense_2 => amount_2, expense_1 => amount_1]. The names of the variables are successfully passed through via the url as amount_1=50, amount_2=50, expense_1=food, expense2=gas, etc... as well as $i, I just dont know how to add those variables to an array each time.
  Right now with this code I'm getting </p>
  
  <p>4
  Array ( [] => ) Array ( [] => ) Array ( [] => ) Array ( [] => )</p>
  
  <p>I apologize if I'm not being clear enough, but I am pretty inexperienced with PHP.</p>