Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>All you need is <a href="http://www.php.net/manual/en/function.uasort.php">uasort</a></strong></p> <pre><code>uasort($list, function ($a, $b) { $a = count($a); $b = count($b); return ($a == $b) ? 0 : (($a &lt; $b) ? -1 : 1); }); </code></pre> <p><strong>Full Example</strong> </p> <pre><code>$list = 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')) ); $list = array_map(function ($v) { uasort($v, function ($a, $b) { $a = count($a); $b = count($b); return ($a == $b) ? 0 : (($a &lt; $b) ? 1 : - 1); }); return $v; }, $list); print_r($list); </code></pre> <p>Output </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_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_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>
 

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