generate a random username function thoughts
I was looking though some of my functions to make more useful web tools from them and i came across the function for generating a username.
I think originally i created this function to generate random usernames for comments so that the user did not have to select a username manually.
I cant remember where i got the list from, but it seems to be quite duplicated.
How the function for username generation works?
- There is a string called usernames with names seperated by spaces.
- Then the names are added to an array using a string to array function.
- There is another string with username prefixes
- The prefix string also gets added to an array
- There is a random function on the loop count to check how many usernames are added to the return string
- Count the total items in the username array
- Pick a random prefix from the array
- Enter the loop
- Shuffle the array
- Pick out an item from the array
- If prefixes are set then add a prefix
- Return the username
Keep it Simple or Make it more Complex?
When i was writing the tool for this i thought, oh i can add this to an api and return a username, but then i have to be able to specify how many names it returns, and then check the list of names that it generates from, should i add more names, where do i get the names from, should the names be in a database or just leave as a string.
It is better to leave it simple or does it benifit from making it more complex.
Keep it simple for the initial tool page, and then make it more complex for the api version and release it on rapid an API to generate usernames.