title: Group subarrays based on column value
body: <p>I have an array:</p>
  <pre><code>[['a', 1], ['b', 1], ['c',2], ['d',2]]
  </code></pre>
  <p>How can I group the subarrays based on the second column value like this:</p>
  <pre><code>[[['a', 1], ['b', 1]], [['c',2], ['d',2]]]
  </code></pre>
  <p>I have an idea to solve this with a foreach, but it may have a way with the built-in functions?</p>
  <p>Sketch with foreach:</p>
  <pre><code>$in = [['a', 1], ['b', 1], ['c',2], ['d',2]];
  $out = [];
  
  foreach($in as $i) {
      $out[$i[1]][] = $i;
  }
  </code></pre>