base 36 Numbering

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

base 36 Numbering

Post by harrisonad »

I am auto-generating a number system to be stored in the database which increments by one like an auto_increment field. But the twist is, I am including [0-9] and [A-Z] in this number system.
Just like Hex Numbering which gives

Code: Select all

00008
00009
00000
0000A
0000B
// .. upto
0000F
00010
But I want to include all remaining letters, [G-Z], which must give...

Code: Select all

0000W
0000X
0000Y
0000Z
00010
I tried to modify a function for hex then changing the base number to 36, but It sucks with all the bugs.
Any idea how can I do this perfectly or almost?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post by harrisonad »

Ooops! seems like I will reinvent the wheel again... :oops:
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

there is something similar in php too, base_convert or something like that.

EDIT: why would you ever want to store that string in the database?
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post by harrisonad »

This serves as tracking number for Requests made by, let's say, remote store branch to main office. Well, i can be contented with auto_increment database column or using md5() or hash() to generate alpha numeric for me, but I want it incremented.
Post Reply