vendredi 14 mars 2014

sort array of arrays by number of elements in sub array


Vote count:

0




I have an array of arrays. I want to sort the containing array so that the sub arrays with the most elements in the array are first.


Example:



$my_array = array(
array(0=>”a", 1=>”b”, 4=>”c"),
array(3=>”z"),
array(0=>”p”, 2=>”k"),
);


Desired result: The sub array with 3 elements is ordered 1st and the sub array with 1 element is ordered last.



$my_array = array(
array(0=>”a", 1=>”b”, 4=>”c"),
array(0=>”p”, 2=>”k"),
array(3=>”z"),
);


asked 56 secs ago

erin

412





Aucun commentaire:

Enregistrer un commentaire