title: Removing null values from an array in PHP
body: <p>I want to remove empty values from an array. I have tried <code>array_filter</code>, <code>array_diff</code> and a custom coded function but nothing helped.</p>
  
  <p>Here's my code that generates the array:</p>
  
  <pre><code>for($i=0;$i&lt;$_POST['size'];$i++)
  {
      $e = array();
      if(!@strcasecmp("yes", $_POST['email'.$i]))
      {
          //array_push($e, $_POST['u'.$i]);
          $e[$i] = $_POST['u'.$i];
      }
      else
      {
          $e[$i] = "";
      }
      //var_dump($e);
  
  var_dump($e);
  }
  </code></pre>
  
  <p>My <code>var_dump</code> outputs:</p>
  
  <pre><code>array (size=1)
    0 =&gt; string '12' (length=2)
  string '12' (length=2)
  array (size=1)
    1 =&gt; string '13' (length=2)
  string '13' (length=2)
  array (size=1)
    2 =&gt; string '' (length=0)
  string '' (length=0)
  array (size=1)
    3 =&gt; string '' (length=0)
  string '' (length=0)
  array (size=1)
    4 =&gt; string '' (length=0)
  string '' (length=0)
  array (size=1)
    5 =&gt; string '' (length=0)
  </code></pre>
  
  <p>How would I remove these empty indexes? Any suggestions are welcome.</p>