title: Multidimensional indexed array to associative array depending on column value
body: <p>I have a multidimensional indexed array. Each element is an associative array with an <code>id</code> column which is unique between elements (its value never repeats within the array).</p>
  
  <pre><code>[indexed] =&gt;Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; john
              [name] =&gt; John
              [age] =&gt; 29
          ),
  
      [1] =&gt; Array
          (
              [id] =&gt; peter
              [name] =&gt; Peter
              [age] =&gt; 30
          ),
  
      [2] =&gt; Array
          (
              [id] =&gt; harry
              [name] =&gt; Harry
              [age] =&gt; 19
          )
  )
  </code></pre>
  
  <p>My goal is to convert this array into a multidimensional associative array, indexed by <code>id</code> values.</p>
  
  <pre><code>[indexed] =&gt;Array
  (
      [john] =&gt; Array
          (
              [id] =&gt; john
              [name] =&gt; John
              [age] =&gt; 29
          ),
  
      [peter] =&gt; Array
          (
              [id] =&gt; peter
              [name] =&gt; Peter
              [age] =&gt; 30
          ),
  
      [harry] =&gt; Array
          (
              [id] =&gt; harry
              [name] =&gt; Harry
              [age] =&gt; 19
          )
  )
  </code></pre>
  
  <p>My best attempt so far is to loop over array elements and manually create the final array.</p>
  
  <pre><code>$associative = array();
  foreach($indexed as $key=&gt;$val) $associative[$val['id']] = $val;
  </code></pre>
  
  <p>I think it's not the most elegant solution. Is it possible to obtain the same result with built-in (more efficient) functions?</p>