Build associative array based on values of another associative array
        Posted  
        
            by macek
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by macek
        
        
        
        Published on 2010-04-21T18:24:35Z
        Indexed on 
            2010/04/21
            18:33 UTC
        
        
        Read the original article
        Hit count: 616
        
I'm looking for an elegant way to turn this array:
Array (
  [foo] => 1
  [bar] => 1
  [zim] => 3
  [dib] => 6
  [gir] => 1
  [gaz] => 3
)
Into this array:
Array (
  [1] => Array ( foo, bar, gir ),
  [3] => Array ( zim, gaz ),
  [6] => Array ( dib )
)
Note:, there is no relationship between the keys or values. They are completely arbitrary and used as examples only. The resulting array should be an associative array grouped by the values of the input array.
Thanks!
© Stack Overflow or respective owner