title: Preserve elements in each row of a two-dimensional array based on another array
body: <p>I have this array:</p>
  <pre><code>0 =&gt; array:3 [
      &quot;product_id&quot; =&gt; &quot;1138&quot;
      &quot;product_image&quot; =&gt; &quot;/resources/medias/shop/products/shop-6500720--1.png&quot;
      &quot;product_sku&quot; =&gt; &quot;6500722&quot;
    ]
  1 =&gt; array:3 [
      &quot;product_id&quot; =&gt; &quot;1144&quot;
      &quot;product_image&quot; =&gt; &quot;/resources/medias/shop/products/shop-6501041--1.png&quot;
      &quot;product_sku&quot; =&gt; &quot;6501046&quot;
    ]
  2 =&gt; array:3 [
      &quot;product_id&quot; =&gt; &quot;113&quot;
      &quot;product_image&quot; =&gt; &quot;/resources/medias/shop/products/shop-6294909--1.png&quot;
      &quot;product_sku&quot; =&gt; &quot;6294915&quot;
  ]
  </code></pre>
  <p>What I am looking for is a way to get a multiple array with only required columns (<code>array_column</code> is not a option, since it's give me only 1 column).</p>
  <p><strong>What I have done</strong></p>
  <pre><code>function colsFromArray($array, $keys)
  {
      return array_map(function ($el) use ($keys) {
          return array_map(function ($c) use ($el) {
              return $el[$c];
          }, $keys);
      }, $array);
  }
  
  $array = array(
      [
          &quot;product_id&quot;    =&gt; &quot;1138&quot;,
          &quot;product_image&quot; =&gt; &quot;/resources/medias/shop/products/shop-6500720--1.png&quot;,
          &quot;product_sku&quot;   =&gt; &quot;6500722&quot;
      ],
      [
          &quot;product_id&quot;    =&gt; &quot;1144&quot;,
          &quot;product_image&quot; =&gt; &quot;/resources/medias/shop/products/shop-6501041--1.png&quot;,
          &quot;product_sku&quot;   =&gt; &quot;6501046&quot;
      ],
      [
          &quot;product_id&quot;    =&gt; &quot;113&quot;,
          &quot;product_image&quot; =&gt; &quot;/resources/medias/shop/products/shop-6294909--1.png&quot;,
          &quot;product_sku&quot;   =&gt; &quot;6294915&quot;
      ]
  );
  colsFromArray($array, array(&quot;product_id&quot;, &quot;product_sku&quot;));
  
  //0 =&gt; array:3 [
  //    &quot;product_id&quot; =&gt; &quot;1138&quot;
  //    &quot;product_sku&quot; =&gt; &quot;6500722&quot;
  //  ]
  //1 =&gt; array:3 [
  //    &quot;product_id&quot; =&gt; &quot;1144&quot;
  //    &quot;product_sku&quot; =&gt; &quot;6501046&quot;
  //  ]
  //2 =&gt; array:3 [
  //    &quot;product_id&quot; =&gt; &quot;113&quot;
  //    &quot;product_sku&quot; =&gt; &quot;6294915&quot;
  //]
  </code></pre>
  <p>The problem is that it seems too <em>laggy</em>, since it iterates twice over this.
  Is there any way to get multiple columns without this workaround?</p>
  <p>I'm using PHP5.6</p>