title: Associative array from form inputs
body: <p>I'm building a calculator for a mmo guild. At this moment I'm looking for a way to make data more easy to access for calcules.</p>
  
  <p>Basically, I have a form with 5 text fields (just for test, there will be a lot more), and a select list (for choose the proper equation).</p>
  
  <p>Example code:</p>
  
  <pre><code>&lt;input type="text" id="strength" name="strength" value="0"&gt;
  &lt;input type="text" id="dexterity" name="dexterity" value="0"&gt;
  &lt;select name="equation" id="equation"&gt;
      &lt;option name="damage" id="damage"&gt;Damage&lt;/option&gt;
      &lt;option name="defense" id="defense"&gt;Defense&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>So this form will be procesed through a php file.</p>
  
  <pre><code>&lt;form action="file.php" method="post"&gt;
      //inputs here
      &lt;input type="submit" value="calculate"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>At this moment I'm receiving all data in php file with vars:</p>
  
  <pre><code>$strength = (int)$_POST['strength'];
  $dexterity = (int)$_POST['dexterity'];
  </code></pre>
  
  <p>For start is ok, but when my script is complete there will be more than 20 fields... so I wanna store all data in an array, something like this:</p>
  
  <pre><code>$strength = array(
  'fuerza' =&gt; 125, 
  'dexterity ' =&gt; 125,
  //and more fields...
  );
  </code></pre>
  
  <p>And use this data in various different functions for equations:</p>
  
  <pre><code>function equation1()
  {
      $damage = $stats['dexterity'] + $stats['strength'];
  }
  </code></pre>
  
  <p>I have read several posts and tutorials about use name value from inputs for create an array somethin like this: name="name[]". But doesn't work for me how I want. This calculator will receive just 1 value for each "stat", and I need have all these values in an array so I can access them from different fuctions in my script.</p>
  
  <p>Please ask me if my question is not clear, and sorry if my english is bad.</p>
  
  <p><strong>EDIT AFTER SOLVE</strong></p>
  
  <p>I let here my code after solve:</p>
  
  <p>.html example:</p>
  
  <pre><code>&lt;input type="text" id="strength" name="stats[strength]" value="0"&gt;
  &lt;input type="text" id="dexterity" name="stats[dexterity]" value="0"&gt;
  &lt;select name="operation" id="operation"&gt;
      &lt;option name="damage" id="damage"&gt;Damage&lt;/option&gt;
      &lt;option name="defense" id="defense"&gt;Defense&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>.php example:</p>
  
  <pre><code>function critOp($stat)
  {
      $result = $stat * 0.00725;
      return $result;
  }
  switch($_POST['operation']){
  case 'damage' : 
      $critical = critOp($_POST["stats"]["dexterity"]);
      break;
  //more case...
  </code></pre>