title: Laravel - converting a collection to a simple array
body: <p>so I have this code:</p>
  
  <pre><code>    $collectionOfProducts = \DB::table('products_specif')-&gt;whereIn('size',$arrayOfAttributes)-&gt;whereIn('color',$arrayOfAttributes)-&gt;whereIn('material',$arrayOfAttributes)-&gt;get('product_code');
      $product_codes = $collectionOfProducts-&gt;unique();
      dd($product_codes-&gt;toArray());
      $arrayOfProducts = \DB::table('products')-&gt;whereIn('product_code',$product_codes)-&gt;get();
      return view('pages.products', compact('arrayOfProducts','type'));
  </code></pre>
  
  <p>the dd() responds with:</p>
  
  <pre><code>array:4 [▼
    0 =&gt; {#1252 ▼
      +"product_code": "SocksCode"
    }
    4 =&gt; {#1257 ▶}
    9 =&gt; {#1262 ▶}
    13 =&gt; {#1266 ▶}
  ]
  </code></pre>
  
  <p>I would like to use the $product_codes in my <strong>whereIn</strong> statement, but I can't because of those numbers at the start(0,4,9,13).
  How do I convert this collection/array to just a simple <strong>"product_code" : "code"</strong> array?</p>