PHP: Merge multi dimensional arrays, grouping by a certain key
问题 I have some arrays like this: array( 'id' => 1, 'title' => 'title1', 'name' => 'name1', 'count' => 2 ) array( 'id' => 1, 'title' => 'title1', 'name' => 'name2', 'count' => 3 ) array( 'id' => 2, 'title' => 'title2', 'name' => 'name1', 'count' => 2 ) I want to merge them so that arrays with same id and title would be merged. The result should be like: array( 'id' => 1, 'title' => 'title1', 'name' => array('name1', 'name2'), 'count' => array(2, 3) ) array( 'id' => 2, 'title' => 'title2', 'name'