PHP Sort array by field? -


possible duplicate:
how sort multidemensional array inner key
how sort array of arrays in php?

how can sort array like: $array[$i]['title'];

array structure might like:

array[0]( 'id' => 321, 'title' => 'some title', 'slug' => 'some-title', 'author' => 'some author', 'author_slug' => 'some-author');  array[1]( 'id' => 123, 'title' => 'another title', 'slug' => 'another-title', 'author' => 'another author', 'author_slug' => 'another-author'); 

so data displayed in asc order based off title field in array?

use usort built explicitly purpose.

function cmp($a, $b) {     return strcmp($a["title"], $b["title"]); }  usort($array, "cmp"); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -