Recently I had to create a code/username maker to fit into a certain type of pattern so that all “broker codes” (as they were called) followed the same path.
An example one looked like so:
The number needed to increment and I wanted to use the auto-increment feature in the mysql database table that was driving this data to make it.
This was easy but I ended up with a code that looked like this:
So I found a built in PHP function which I somehow managed to overlook for years and years and years.
The magic function this time around is called… str_pad() and I used it like this to get the result I was after: