title: Assign value from array as key and merge records of same key
body: <p>I have array like below in PHP (Codeigniter). I want to group them by using country names. So value of country key will become key of outer array</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [city] =&gt; Buenos Aires
              [country] =&gt; Argentina
          )
  
      [1] =&gt; Array
          (
              [city] =&gt; Adelaide
              [country] =&gt; Australia
          )
  
      [2] =&gt; Array
          (
              [city] =&gt; Brisbane
              [country] =&gt; Australia
          )
  
      [3] =&gt; Array
          (
              [city] =&gt; Fremantle
              [country] =&gt; Australia
          )
  
      [4] =&gt; Array
          (
              [city] =&gt; Melbourne
              [country] =&gt; Australia
          )
  
      [5] =&gt; Array
          (
              [city] =&gt; Sydney
              [country] =&gt; Australia
          )
  
  )
  </code></pre>
  
  <p>I want to convert it into array like below so country will become key with city list as per country name</p>
  
  <pre><code>Array
  (
      [Argentina] =&gt; Array
      (
          [0] =&gt; Buenos Aires
      )
  
      [Australia] =&gt; Array
      (
          [0] =&gt; Adelaide
          [1] =&gt; Brisbane
          [2] =&gt; Melbourne
          [3] =&gt; Sydney
      )
  
  )
  </code></pre>