title: Postgres unnest multidimensional array to columns?
body: <p>Based on previous posts, I can unnest a multidimensional array to an integer[], however I would like to be able to create multiple columns:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION unnest_2d_1d(ANYARRAY, OUT a ANYARRAY)
    RETURNS SETOF ANYARRAY AS
  $func$
  BEGIN
     FOREACH a SLICE 1 IN ARRAY $1 LOOP
        RETURN NEXT;
     END LOOP;
  END
  $func$  LANGUAGE plpgsql IMMUTABLE;
  </code></pre>
  
  <p>Then if I execute:</p>
  
  <p><code>select unnest_2d_1d(array[[1,2],[4,5]]);</code></p>
  
  <p>Result:</p>
  
  <h2><em>column</em></h2>
  
  <p>12</p>
  
  <p>45</p>
  
  <p>However what I am trying to achieve is:</p>
  
  <h2> <em>column1 | column2</em></h2>
  
  <p>1       |     2</p>
  
  <p>4       |     5</p>
  
  <p>I also tried to unnest the result but it didnt work as it only creates a unique column with all the information</p>