title: Group rows of a multidimensional array and form comma-separated values within each group
body: <p>I want to combine arrays having same category id and question id.</p>
  <p>Sample input:</p>
  <pre><code>$array = [
      [
          'category_id' =&gt; 1,
          'question_id' =&gt; 1,
          'option_id' =&gt; 2,
          'title' =&gt; 'Do you wear glasses?',
          'answer' =&gt; 'no'
      ],
      [
          'category_id' =&gt; 1,
          'question_id' =&gt; 2,
          'option_id' =&gt; 3,
          'title' =&gt; 'Your hobbies ?',
          'answer' =&gt; 'movies'
      ],
      [
          'category_id' =&gt; 1,
          'question_id' =&gt; 4,
          'option_id' =&gt; 8,
          'title' =&gt; 'what is your status?',
          'answer' =&gt; 'single'
      ],
      [
          'category_id' =&gt; 1,
          'question_id' =&gt; 2,
          'option_id' =&gt; 1,
          'title' =&gt; 'Your hobbies ?',
          'answer' =&gt; 'travel'
      ],
  ];
  </code></pre>
  <p>The 2nd and 4th arrays contain the same question (same category id and same question id), so I would like to have their answer values merged together as a comma-separated string.</p>
  <p>Desired result:</p>
  <pre><code>Array(
  [0] =&gt; Array
      (
          [category_id] =&gt; 1
          [question_id] =&gt; 1
          [option_id] =&gt; 2
          [title] =&gt; Do you wear glasses?
          [answer] =&gt; no
      )
  
  [1] =&gt; Array
      (
          [category_id] =&gt; 1
          [question_id] =&gt; 2
          [option_id] =&gt; 3
          [title] =&gt; Your hobbies ?
          [answer] =&gt; movies,travel
      )
  
  [2] =&gt; Array
      (
          [category_id] =&gt; 1
          [question_id] =&gt; 4
          [option_id] =&gt; 8
          [title] =&gt; what is your status?
          [answer] =&gt; single
      )
  ) 
  </code></pre>
  <p>It is okay that the option id and title are overwritten while grouping because I am not using the option id and the title values will be identical within each group.</p>