justineaguas Posted November 14, 2009 Share Posted November 14, 2009 I am creating a website for my project in school. Our professor requires the username of our clients to have a format. For example.. First Name: John Last Name: Williams Middle Initial: S and the username should be like jswilliams It will get the first letter of the firstname, the middle initial and the whole last name. all lower-cased characters. I have been playing with a lot of codes however I can't seem to find the correct one. I always end up wrong. How do I do this? Quote Link to comment Share on other sites More sharing options...
smerny Posted November 14, 2009 Share Posted November 14, 2009 try this $username = strtolower($first[0] . $middle . $last); Quote Link to comment Share on other sites More sharing options...
alpine Posted November 14, 2009 Share Posted November 14, 2009 Should handle several pitfalls $username = strtolower(join(str_replace(" ", "", array(substr(ltrim($firstname),0,1),substr(ltrim($middlename),0,1),ltrim($lastname))))); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.