Note that there are some explanatory texts on larger screens.

plurals
  1. POSorting array by count of subarray
    text
    copied!<p>I have an array looking like this:</p> <pre><code>Array( ['some_first_category'] =&gt; Array( ['some_first_name'] =&gt; Array( [0]=&gt;'first@email.com', [1]=&gt;'second@email.com', [2]=&gt;'third@email.com', [3]=&gt;'fourth@email.com' ) ['some_second_name'] =&gt; Array ( [1]=&gt;'first@email.com', [2]=&gt;'second@email.com') ['some_third_name'] =&gt; Array( [1]=&gt;'first@email.com', [2]=&gt;'second@email.com', [3]=&gt;'third@email.com', [4]=&gt;'fourth@email.com' ) ['some_second_category'] =&gt; Array( ['some_first_name'] =&gt; Array( [0]=&gt;'first@email.com' ) ['some_second_name'] =&gt; Array( [1]=&gt;'first@email.com', [2]=&gt;'second@email.com', [3]=&gt;'third@email.com', [4]=&gt;'fourth@email.com') ['some_third_name'] =&gt; Array( [1]=&gt;'first@email.com', [2]=&gt;'second@email.com')) </code></pre> <p>And I want to sort the array by the number of values of that has the names, In my case I want to become this array:</p> <pre><code>Array( ['some_first_category'] =&gt; Array( ['some_third_name'] =&gt; Array( [1]=&gt;'first@email.com', [2]=&gt;'second@email.com', [3]=&gt;'third@email.com', [4]=&gt;'fourth@email.com' ) ['some_first_name'] =&gt; Array( [0]=&gt;'first@email.com', [1]=&gt;'second@email.com', [2]=&gt;'third@email.com', [3]=&gt;'fourth@email.com' ) ['some_second_name'] =&gt; Array ( [1]=&gt;'first@email.com', [2]=&gt;'second@email.com') ['some_second_category'] =&gt; Array( ['some_second_name'] =&gt; Array( [1]=&gt;'first@email.com', [2]=&gt;'second@email.com', [3]=&gt;'third@email.com', [4]=&gt;'fourth@email.com') ['some_third_name'] =&gt; Array( [1]=&gt;'first@email.com', [2]=&gt;'second@email.com') ['some_first_name'] =&gt; Array( [0]=&gt;'first@email.com' )) </code></pre> <p>This means sorting categories by name by the number(count) of values of the names. Someone can help me? Thanks in advance,</p> <p>Aäron</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload