Hello,
I need some, maybe a lot of help incrementing alphanumeric values. For example,
00000000000A
00000000000B
00000000000C
00000000000D and so on
Then
000000000001 through 9
Then
0000000000AA
0000000000AB
0000000000AC
0000000000AD
All the way through 0000000000A9
And continue this pattern until all possible combinations are used.
I know it’s a lot 36 ^12 I think but I will only be assigning them in 1k chunks.
Can you help?
Thanks
incrementing alphanumeric values
Moderator: General Moderators
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
Re: incrementing alphanumeric values
you mean a-z then 1-9?
id really like to see the solution for this when you find one, please remember to come back and post.
i know that there are some classes out there to simulate enumerations in php you may be able to dig those up and use those.
but if you are trying to create a base (36?) number system. aside from using lists i wouldn't know where to start.
id really like to see the solution for this when you find one, please remember to come back and post.
i know that there are some classes out there to simulate enumerations in php you may be able to dig those up and use those.
but if you are trying to create a base (36?) number system. aside from using lists i wouldn't know where to start.
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
Re: incrementing alphanumeric values
ha, sexy, look what i found:
http://en.wikipedia.org/wiki/Base_36
its called hexatridecimal.
what are you using this for?
http://en.wikipedia.org/wiki/Base_36
its called hexatridecimal.
i'd say convert to base 10 and back again.<?php
$base_36 = "ZAQFG"; //Sample Base 36 Number
$decimal = "7654321"; //Sample Decimal Number
echo base_convert($base_36,36,10); //Outputs $base_36 converted to decimal
echo base_convert($decimal,10,36); //Outputs $decimal converted to base 36
?>
what are you using this for?
Re: incrementing alphanumeric values
Hi, daedalus__
In our case the alpha needs to be caps but that’s not a big deal. We want to use this numbering format as serial numbers for parts.
Also, being PHP incrementing in alpha its just.
So if I’m doing single digits it’s easy but I get lost when I need to build the 12 digit string starting with the leading zeros. I’m sure I could just start by doing this
Over the course of 20 years or so it would cover all the alpha but what do I do when its time to put in 0-9?
Or more realistically if I needed to start the serial number at the point where there are numbers in the string.
Base 36 counting is I’m sure the right starting point but for example on the right most digit once I’ve counted A – 9 how do I move that count one place to the left and start the count again?
Thanks,
incubi
In our case the alpha needs to be caps but that’s not a big deal. We want to use this numbering format as serial numbers for parts.
Also, being PHP incrementing in alpha its just.
Code: Select all
for($x="A"; $x < "ZZ"; $x++)
print $x."\r";
Code: Select all
for($x="A"; $x < "ZZZZZZZZZZZZ"; $x++)
print $x."\r";
Or more realistically if I needed to start the serial number at the point where there are numbers in the string.
Base 36 counting is I’m sure the right starting point but for example on the right most digit once I’ve counted A – 9 how do I move that count one place to the left and start the count again?
Thanks,
incubi