title: How to count a dynamic HTML form input array with PHP?
body: <p>I have a button on a page that when a user pushes it, it creates another "Contact" field on the page. The Contact field allows them to add a new contact to their profile. Also, they can click the button as many times as they want, and it will create that many "Contact" fields.</p>
  
  <p>The problem though is that I am having a hard time figuring how many "Contact" fileds have been added. Here is some HTML that is generated when the button is clicked:</p>
  
  <pre><code>&lt;div class="item"&gt;
      &lt;label for="in-1v"&gt;First Name &lt;span&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;div class="text"&gt;
          &lt;input type="text" id="in-1-0" name="member[0][fname]" value="" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="item"&gt;
      &lt;label for="in-2-0"&gt;Last Name &lt;span&gt;*&lt;/span&gt;&lt;/label&gt;
      &lt;div class="text"&gt;
          &lt;input type="text" id="in-2-0" name="member[0][lname]" value="" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>Each time the button is clicked, name="member[0][lname]" will become name="member[<strong>1</strong>][lname]" and will continue to increment each time the button is clicked. As stated earlier, the user can do this as many times as they want on the page.</p>
  
  <p>I am using PHP to loop through the multidimensional array:</p>
  
  <pre><code>$array = $_POST['member'] ;
  foreach($array as $array_element) {
    $fname = $array_element['fname'];
    $lname = $array_element['lname'];
  }
  </code></pre>
  
  <p>How can I use PHP to determine how many fileds have been added so I can loop through them? </p>
  
  <p>Any help is greatly appreciated!</p>