Skip to content
Advertisement

Generate random username based on full name php

I want to grab the first name in lowercase then concatenate the first two characters after the space and finally concatenate that with a random number from 0 to 100. So if my name is "Mike Test" I want the output to be: mikete3

JavaScript

My function outputs “mike te84” and I don’t know how to remove that space.

Advertisement

Answer

Try this, always use trim to remove extra space.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement