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
Post a Comment