title: How to validate email input?
body: <p>I'm using the WordPress API to create an options page. One of the inputs need to have an email entered. I need to write a function that will validate the email entered and return it.</p>
  
  <pre><code>        function nl_validate_settings( $input ) {
              if ( $field_args = array( 'type' =&gt; 'email' ) ) {
                  foreach( $input as $email ) {
                      if ( ! preg_match( '/^[A-Za-z0-9!#$%&amp;\'*+\/=?^_`{|}~-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+[A-Za-z]$/', $email ) ) {
                          $email = "Invalid email address!";
                      }
                  }
                  return $email;
              }
                      }
  </code></pre>
  
  <p>This isn't working and I don't know what I am doing wrong. It doesn't save emails when an email is entered correctly. </p>
  
  <p>I've checked other answers on StackOverFlow but couldn't find anything that would fix the problem. Your help would be appreciated!</p>
  
  <p>I don't know how to format it</p>