Group a multidimensional array by a Key value?
<blockquote>
  <p>I have an multi dimensional array i am trying to group the array based on the key value.</p>
  
  <p>So, I'm trying to group them by key but i am not getting to group the
  array based on the key values.</p>
  
  <p>Below is the original array </p>
</blockquote>

<pre><code> Array
    (
        [0] =&gt; Array
            (
                [User] =&gt; Array
                    (
                        [id] =&gt; 2
                        [feature] =&gt; AddUser
                        [feature_level] =&gt; 1
                        [parent_feature] =&gt; 1
                    )

            )

        [1] =&gt; Array
            (
                [User] =&gt; Array
                    (
                        [id] =&gt; 3
                        [feature] =&gt; EditUser
                        [feature_level] =&gt; 1
                        [parent_feature] =&gt; 1
                    )

            )

        [2] =&gt; Array
            (
                [Candidate] =&gt; Array
                    (
                        [id] =&gt; 5
                        [feature] =&gt; AddCandidate
                        [feature_level] =&gt; 1
                        [parent_feature] =&gt; 4
                    )

            )

        [3] =&gt; Array
            (
                [Candidate] =&gt; Array
                    (
                        [id] =&gt; 6
                        [feature] =&gt; EditCandidate
                        [feature_level] =&gt; 1
                        [parent_feature] =&gt; 4
                    )

            )

    )
</code></pre>

<blockquote>
  <p>What i need is</p>
</blockquote>

<pre><code>   Array (

   [User] =&gt; Array (
          [0] =&gt; Array (
                    [id] =&gt; 2
                    [feature] =&gt; AddUser
                    [feature_level] =&gt; 1
                    [parent_feature] =&gt; 1
                    )
          [1] =&gt; Array (
                    [id] =&gt; 3
                    [feature] =&gt; EditUser
                    [feature_level] =&gt; 1
                    [parent_feature] =&gt; 1
                    )
          )

   [Candidate] =&gt; Array (
          [0] =&gt; Array (
                    [id] =&gt; 5
                    [feature] =&gt; AddCandidate
                    [feature_level] =&gt; 1
                    [parent_feature] =&gt; 4
                 )

          [1] =&gt; Array (
                    [id] =&gt; 5
                    [feature] =&gt; EditCandidate
                    [feature_level] =&gt; 1
                    [parent_feature] =&gt; 4
                 )
          )

)
</code></pre>