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? Link to comment https://forums.phpfreaks.com/topic/181459-formatting-username-question/ 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); Link to comment https://forums.phpfreaks.com/topic/181459-formatting-username-question/#findComment-957239 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))))); Link to comment https://forums.phpfreaks.com/topic/181459-formatting-username-question/#findComment-957263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.