PHP sort array of associative arrays by element size / string size -


is there way sort array of associative arrays length of 1 of elements? trying order arrays largest smallest description length.

$some_array = []; $some_array[0] = ['name'=>'a name','description'=>'a description']; $some_array[1] = ['name'=>'a name1','description'=>'a description 1']; $some_array[2] = ['name'=>'a name2','description'=>'a description 2 third array element']; $some_array[3] = ['name'=>'a name3','description'=>'a description three']; 

with above example $some_array[2] should come first followed 3 1 0.

php >= 5.5.0 needed array_column:

array_multisort(array_map('strlen', array_column($some_array, 'description')),                 sort_desc,                 $some_array); 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -