View Full Version : Alphanumeric Increments - Advanced

02-06-2009, 12:29 AM

So, I have used base_convert("467363",10,36); which turns a number into an alphanumeric code.

You see, I want the following pattern for code making:

etc etc

Now, the base_convert function transforms a decimal into these codes, however it only converts the alphanumeric being 0-9 a-z but not A-Z.

This means there are 36 x 36 x 36 combinations, instead of the desired 64 x 64 x 64. Which means there are 4 times less combinations that required.

Does anyone know of any way to convert a decimal into a alphanumeric code with Uppercase characters?

Thanks in advance

02-06-2009, 01:08 AM
Did you look at this yet?

Especially, scroll down to the example by "Fragmer" ...
that author specifically discusses (0-1a-zA-Z).
(That post is a little over 1/2 down the page)
He has a universal convert up to Base-62.

02-06-2009, 01:15 AM
Lol, thank you. It's funny how when you really need something you can never find it! I looked over that page a few times earlier, ah well.

Thanks Dude, this is exactly what I'm after!

02-06-2009, 01:34 AM
... and let us know what top-secret code you're working on Mr. Scherbius ;)

02-06-2009, 02:07 AM
Lol, its basically for a slightly neater and logical way to reference codes relating to database entries. For example, for support tickets stored in a database, you wont need the CODE column anymore, as you would take the auto-incrementing ID field and convert it into the alphanumeric code. This not only saves space in the Database, 3 or 4 bytes per row (small, but soon adds up).

If you also do the same with the client ID relating to the support ticket you can get 2Hn-F7g3 for example, which to the untrained eye is complete garbage, but to the cool people it actually means something.

Plus it saved URL space. 3843 = ZZ, 238327 = ZZZ, 14776335 = ZZZZ. So you're saving 50% of the URL space too.

By the way, have you ever heard of OCD? LOL

02-06-2009, 02:36 PM
Being 48, I've lived in the pre-PC days when the programmers only had 4K of RAM
to cram their programs into. You save every byte you can. So technically, it's noble to
conserve so much storage, but is it out-weighed by the processing time to do the

One could argue that if you only allow a username of 10 characters instead of 20,
you would also save 50% in storage (for that particular data).

With storage costs so low and seemingly endless, perhaps the burden is now on CPU
usage and processing, rather than disk space. I guess I would put more emphasis on
pre-defining string/integer/floats and lengths ... much like C++. With such definitions,
the processor knows ahead of time "what the data is" ... much more efficient than
"how much data there is".

But I see where you're going with this. An interesting project never-the-less.