title: Cleaning up array elements from a form
body: <p>I have a form that uses inputs to create and array. The  inputs are not all required but at least one is.</p>
  
  <pre><code>&lt;form method="post" action="process.php"&gt;
      &lt;input type="text" name="MAC[]" maxlength="12" /&gt;
      &lt;input type="text" name="MAC[]" maxlength="12" /&gt;
      &lt;input type="text" name="MAC[]" maxlength="12" /&gt;
      &lt;input type="text" name="MAC[]" maxlength="12" /&gt;
      &lt;input class="submitbg" type="submit" value="Register" name="submit"/&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>Now on process.php I want to loop through the array remove two types of special characters <code>:</code> <code>;</code> then make all upper case, and verify there are only 12 characters and then serialize the arrray.</p>
  
  <pre><code>$my_array = $_POST['MAC'];
  foreach ($my_array as $val){
      $val = strtoupper($val);
      $val = str_replace(";","",$val);
      $val = str_replace(":","",$val);
      $val = trim($val);
      if (strlen($val) != 12)){
          $valid = false;
          $error = "Your MAC address is not 12 characters long";
      }
  }
  $mac_addresses = serialize($my_array);
  
  // if valid is not false do something with the cleaned up array.
  </code></pre>
  
  <p>The questions:</p>
  
  <ol>
  <li>Will my foreach loop save the updated values back into the array?</li>
  <li>How to check to make sure there is at least one array value?</li>
  </ol>