I have an array with user names:
$a = array('user1','user2');
I want to use them to output the users' information in a list, but I need it sorted by their name, which I pull from the database within the foreach loop that lists them. How do I sort it?
foreach($a as $b) {
$user = $users->getUser($b); // gets user's details from the database
$name = $user['name']; // I want the list to be sorted by this variable
echo $name.'<br />';
}
The names aren't unique, for example user1 and user1 might both be named John Smith. Only the usernames are unique.