1, 'user_name' => 'Navn1'), array('user_id' => 2, 'user_name' => 'Navn2'), array('user_id' => 3, 'user_name' => 'Navn3')); } function build_user_url($user_id) { return BASEDIR . "profile.php?lookup=$user_id"; } function build_user_link($user_id, $user_name) { $url = build_user_url($user_id); return "$user_name"; } function human_language_implode($glue, $lastglue, $a) { if(count($a) == 0) { return ''; } else if(count($a) == 1) { return $a[0]; } else { return implode($glue, array_slice($a, 0, count($a) - 1)) . $lastglue . $a[count($a) - 1]; } } function build_user_list($all_users) { $user_list_array = array_map(function($user) { return build_user_link($user['user_id'], $user['user_name']); }, $all_users); return human_language_implode(",\r\n", " og\r\n", $user_list_array); } $all_users = get_users_from_database(); $user_list = build_user_list($all_users); echo $user_list; ?>