title: How To Validate Hex Colors using loop regex and an array?
body: <p>I have two colorpicker fields and I am using <code>preg_match</code> to validate them. This is a <b>working</b> code, <b><i>it validates as expected.</i></b> <br/>It looks like this (I will give code for first field because second field is basically the same):</p>
  
  <pre><code>function display_bg_setting($args){
  //Get our options from register settings (my_theme_color_options);
  $GetColorpickerValue = (array) get_option('my_theme_color_options');
  
  if(isset($GetColorpickerValue['display_bg'])) {
  $get_options = $GetColorpickerValue['display_bg'];
  }   else {
       $GetColorpickerValue['display_bg']='';
       $get_options = $GetColorpickerValue['display_bg'];
      }
  echo'&lt;input type="text" id="display_bg" value="'.$get_options.'" name="my_theme_color_options[display_bg]" /&gt;';
  </code></pre>
  
  <p><b>Now The Question:</b> <br/><br/>Obviously i will have a lot more colorpicker fields in my theme (15-20 fields) so instead validating every single field like in the code above I tried to use a callback function and validate my colors simultaneously. This is where I am failing and  my code does not validate colors.</p>
  
  <p>The callback looks like this:</p>
  
  <pre><code>  function validate_color_options_and_other_fields($options){
    //My two colopickers fields stored as an array
    $option = array($options['wrapper_background_color'],$options['display_bg']);
  
    foreach($option as $options){
      if(preg_grep('/#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?\b/', $options)) //hex color is valid
  
      {
           return $options;//Returns colorpicker fields
      } 
  
  
       else {//Returns blank
       $options['wrapper_background_color']='';
       $options['display_bg']='';
       } 
  
      }//End foreach
  
  
     return $options;//Returns all other options(checkboxses,select fields...)
  
  
  }//Function end
  </code></pre>
  
  <p>This is what I am trying to do: <br/>I put some <b><i>non-color value</i></b> on <b>first field</b> and <b><i>real color</i></b> on <b>second field</b> so the output would be <b>nothing</b> on first field and <b>real color</b> on second field and vice versa.(This is the part where my callback fails.). <br/>Or I put some <b><i>non-color values</i></b> on <b>both fields</b> and it returns <b>nothing</b> on both fields (This is the part where my callback works.) </p>
  
  <p><br/>Can you guys help me out with this?  </p>