title: How to return array with custom key mapWithKeys?
body: <p>This is code that iterate collection in Laravel:</p>
  
  <pre><code>$usersData = $users-&gt;mapWithKeys(function ($item) {
      return [$item-&gt;id =&gt; array("name" =&gt; $item-&gt;name, "email" =&gt; $item-&gt;email, "id" =&gt; $item-&gt;id)];
   });
  </code></pre>
  
  <p>I tried to get array <code>$usersData</code> with custom <code>key</code> and value as array.</p>
  
  <p>But in result I get this:</p>
  
  <pre><code>array:1 [  0 =&gt; array:3 [    "name" =&gt; "Doctor"    "email" =&gt; "doctor@il.com"    "id" =&gt; 2  ]]
  </code></pre>
  
  <p>Instead key <code>2</code> I have key <code>0</code> for element of array.</p>