Jump to content

If it starts with a number, change it...


jj20051

Recommended Posts

I have a username generator that takes the first 8 characters from an entered domain name to make the username. How would I change it so that if the domain begins with a number it adds a "t" or something similar t the username?

 

$username = preg_replace("/[\.,\";'\:]/", "", $domain);
$username = substr($username, 0, ;

 

Between those two lines it would have to add the letter to the front of the username if the username started with a number...

 

Examples:

example.com ---> Username: exampleco

0303mg.org ---> Username: t0303mgo

my0domains.com ---> Username: my0domai

002domain.com ---> Username: t002doma

 

Hopefully you understand what I'm trying to do...

Link to comment
https://forums.phpfreaks.com/topic/208881-if-it-starts-with-a-number-change-it/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.