title: Collection to associative array with specific keys [L5.2]
body: <p>I have the next collection: </p>
  
  <pre><code>Collection {#356 ▼
    #items: array:31 [▼
      0 =&gt; {#359 ▼
        +"id": 17
        +"zone_id": 2
        +"name_de": "Österreich"
        +"name_en": "Austria"
        +"name_iso": "AUSTRIA"
        +"tld": "at"
        +"iso3166": "AT"
        +"phone": 43
        +"vat_regex": "/^U[0-9]{8}$/"
        +"shop_id": 17
        +"country_id": 165
      }
      1 =&gt; {#360 ▼
        +"id": 2
        +"zone_id": 2
        +"name_de": "Belgien"
        +"name_en": "Belgium"
        +"name_iso": "BELGIUM"
        +"tld": "be"
        +"iso3166": "BE"
        +"phone": 32
        +"vat_regex": "/^[01][0-9]{9}$/"
        +"shop_id": 17
        +"country_id": 25
      }]
  }
  </code></pre>
  
  <p>And I want to get the next result as associative array:</p>
  
  <pre><code>[
      "AT" =&gt; "Austria",
      "BE" =&gt; "Belgium"
  ]
  </code></pre>
  
  <p>I'm trying to do it using:</p>
  
  <pre><code>$keyed = $countries-&gt;map(function ($item) {
       return [$item-&gt;iso3166 =&gt; $item-&gt;name_en];
  });
  </code></pre>
  
  <p>But I'm getting:</p>
  
  <pre><code>Collection {#357 ▼
    #items: array:31 [▼
      0 =&gt; array:1 [▼
        "AT" =&gt; "Austria"
      ]
      1 =&gt; array:1 [▼
        "BE" =&gt; "Belgium"
      ]
    ]
  }
  </code></pre>
  
  <p>What I'm doing wrong or how can I achieve the associative array? </p>
  
  <p><em>Note: I'm using Laravel 5.2 so <strong>mapWithKeys()</strong> Collection method is not implemented.</em></p>