sort array by specific key value alphabetically php code example
Example 1: php sort array by specific key
usort($array, function ($a, $b) {
return ($a['specific_key'] < $b['specific_key']) ? -1 : 1;
});
Example 2: php order array by specific key
function cmp($a, $b)
{
return strcmp($a->display_name, $b->display_name);
}
usort($blogusers, "cmp");
foreach ($blogusers as $bloguser)
{
...