The other answers are correct, but it’s possible to achieve the same thing with less code using
$users = get_users();
$user_names = wp_list_pluck( $users, 'display_name' );
wp_list_pluck() used that way will get the
display_name field of all the users in an array without needing to do a loop.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.