title: Codeigniter using form validation function "matches" with sub-array POST
body: <p>Just started with CI last week and got this issue. What to put inside the <code>matches</code> function if I'm passing the form data as an array? </p>
  
  <p>I use array in the html form to locate all input fields inside single array in case I want to pass user generated input such as multiple phone numbers or emails. So everything is placed in array such as this: </p>
  
  <pre><code>    &lt;div&gt;
          &lt;label for="password"&gt;Password&lt;/label&gt;
          &lt;input type="password" name="input[password]" id="password" value="&lt;?php echo set_value("input[password]")?&gt;"/&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;label for="password"&gt;Confirm Password&lt;/label&gt;
          &lt;input type="password" name="input[conf_password]" id="conf_password" value="&lt;?php echo set_value("input[conf_password]")?&gt;"/&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p><strong>Notice the <code>*name="input[password]"*</code></strong></p>
  
  <p>The validation works like a charm for all except when I use the function <code>matches</code>:</p>
  
  <pre><code>$this-&gt;form_validation-&gt;set_rules("input[password]", "Password", 'required|matches[input[conf_password]]');
  
  $this-&gt;form_validation-&gt;set_rules("input[conf_password]", "Confirm Password", 'required');
  
  matches[input[conf_password]]
  </code></pre>
  
  <p>This will not work because after I checked the Form_Validation.php I found out that <code>matches</code> will take whatever string I put between the square brackets of <code>matches</code> and tries to fetch the value from <code>$_POST</code> directly. </p>
  
  <p>CI codes: </p>
  
  <pre><code>/**
       * Match one field to another
       *
       * @access  public
       * @param   string
       * @param   field
       * @return  bool
       */
      public function matches($str, $field)
      {
          if ( ! isset($_POST[$field]))
          {
              return FALSE;
          }   
          $field = $_POST[$field];    
          return ($str !== $field) ? FALSE : TRUE;
      }
  </code></pre>
  
  <p>So by right there would be no such thing as <code>$_POST[input[conf_password]]</code>. </p>
  
  <p>I'm aware that I can solve this by using </p>
  
  <ol>
  <li>custom validation function</li>
  <li>compare directly $_POST["input"]["password"] === $_POST["input"]["conf_password"]</li>
  </ol>
  
  <p>I'm not sure what I'm missing since everything in CI related to forms is working nicely with arrays, why wouldn't this function? </p>