title: How to remove empty and null values from an array in php?
body: <p>I want to remove the empty and null values from <code>$listValues</code> array.
  Here I am removed the empty values using <code>array_filter</code>.
  Sample Code:</p>
  
  <pre><code>$listValues = array("one", "two", "null","three","","four","null");
  $resultValues = array_filter($listValues);
  
  echo "&lt;pre&gt;";
  print_r($resultValues);
  echo "&lt;/pre&gt;";
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>Array ( [0] =&gt; one [1] =&gt; two [2] =&gt; null [3] =&gt; three [5] =&gt; four [6] =&gt; null ) 
  </code></pre>
  
  <p>But I want</p>
  
  <pre><code>Array ( [0] =&gt; one [1] =&gt; two [3] =&gt; three [5] =&gt; four ) 
  </code></pre>
  
  <p>Any advice greatly appreciated.</p>