Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Lightbulb Alphanumeric Increments - Advanced

    Ok,

    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:

    001
    002
    ....
    009
    00a
    00b
    ...
    00z
    00A
    00B
    ...
    010
    011
    012
    ...
    01a
    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

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Did you look at this yet?
    http://us2.php.net/base_convert

    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.

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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!

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    ... and let us know what top-secret code you're working on Mr. Scherbius

  • #5
    New Coder
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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
    conversions?

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •