title: Remove element from array using array_map
body: <p>I use array_map to validate each array element. If it does not pass the validation it should be removed from the initial array:</p>
  
  <pre><code>$array = (123, 456);
  
  $array = array_map(function ($e){
  
     if( !is_numeric($e) ){
        unset($e); 
        return; //this way i get a NULL element
     }
  
     $return $e;
  
  }, $array);
  </code></pre>
  
  <blockquote>
    <p>OUTPUT: array(3) { [0]=> int(523) [1]=> int(555) [2]=> NULL }</p>
  </blockquote>
  
  <p>Of course, I could add at the end something like:</p>
  
  <pre><code>$array = array_filter($array, 'strlen');
  </code></pre>
  
  <p>But isn't there a way to do this within array_map ? </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Regarding this subject, i forgot to mention a case. What if i want to unset the entire array if one element didn't pass the validation? Can this be done with array_filter , array_map or anything else? I don't want to loop through the array with a for and so on.</p>