title: preg_match_all and empty keys
body: <p>I'm trying to match two regex using a single <code>preg_match_all</code> and I need to get 2 arrays containing the matches.</p>
  
  <p>This is my current code:</p>
  
  <pre><code>$s = 'abab';
  preg_match_all('/(a)|(b)/', $s, $a); 
  var_dump($a);
  </code></pre>
  
  <p>It works quite well, if don't consider that the resulting multi-dimensional array is:</p>
  
  <pre><code>array (size=3)
    0 =&gt; 
      array (size=4)
        0 =&gt; string 'a' (length=1)
        1 =&gt; string 'b' (length=1)
        2 =&gt; string 'a' (length=1)
        3 =&gt; string 'b' (length=1)
    1 =&gt; 
      array (size=4)
        0 =&gt; string 'a' (length=1)
        1 =&gt; string '' (length=0)
        2 =&gt; string 'a' (length=1)
        3 =&gt; string '' (length=0)
    2 =&gt; 
      array (size=4)
        0 =&gt; string '' (length=0)
        1 =&gt; string 'b' (length=1)
        2 =&gt; string '' (length=0)
        3 =&gt; string 'b' (length=1)
  </code></pre>
  
  <p>So, I could use <code>$a[1]</code> and <code>$a[2]</code> but as you can see, these array have empty values on the "not matched" keys.</p>
  
  <p>I'd need:</p>
  
  <pre><code>array (size=3)
    0 =&gt; 
      array (size=4)
        0 =&gt; string 'a' (length=1)
        1 =&gt; string 'b' (length=1)
        2 =&gt; string 'a' (length=1)
        3 =&gt; string 'b' (length=1)
    1 =&gt; 
      array (size=2)
        0 =&gt; string 'a' (length=1)
        1 =&gt; string 'a' (length=1)
    2 =&gt; 
      array (size=2)
        0 =&gt; string 'b' (length=1)
        1 =&gt; string 'b' (length=1)
  </code></pre>
  
  <p>There is some parameter to pass to <code>preg_match_all</code> to get a clean output without empty values? I've already tried <code>array_filter()</code> but it doesn't remove them <strong>and I'm looking for a short solution so I can't use the callback of array_filter</strong> (need it for a code-golf challenge).</p>