title: Recursively remove empty elements and subarrays from a multi-dimensional array
body: <p>I can't seem to find a simple, straight-forward solution to the age-old problem of removing empty elements from arrays in PHP.</p>
  
  <p>My input array may look like this:  </p>
  
  <pre><code>Array ( [0] =&gt; Array ( [Name] =&gt; [EmailAddress] =&gt; ) ) 
  </code></pre>
  
  <p>(And so on, if there's more data, although there may not be...)</p>
  
  <p>If it looks like the above, I want it to be <strong>completely empty</strong> after I've processed it.</p>
  
  <p>So <code>print_r($array);</code> would output:</p>
  
  <pre><code>Array ( )
  </code></pre>
  
  <p>If I run <code>$arrayX = array_filter($arrayX);</code> I still get the <strong>same</strong> <code>print_r</code> output.  Everywhere I've looked suggests this is the simplest way of removing empty array elements in PHP5, however.</p>
  
  <p>I also tried <code>$arrayX = array_filter($arrayX,'empty_array');</code> but I got the following error:</p>
  
  <blockquote>
    <p>Warning: array_filter() [function.array-filter]: The second argument, 'empty_array', should be a valid callback</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>