Forum Moderators: coopster

Message Too Old, No Replies

Convert Long Integer to Short Alphanumeric String

         

Jeremy_H

6:50 pm on Dec 4, 2006 (gmt 0)

10+ Year Member



Hello,

I have a variable set as a vary long integer. This integer is unique to the user.

What I am trying to do is to cut down on the length of the integer, while still maintaining its uniqueness.

I'm thinking somehow converting this number from being numeric (10 characters) to alphanumeric (36 characters) will help me cut this number by more than a third.

I'm looking at different options, but things such as sprintf's conversion to an octal or hexadecimal number will not accomplish what I need.

Is there a PHP function that does something like this?

Thanks

Jeremy_H

1:38 am on Dec 5, 2006 (gmt 0)

10+ Year Member



Upon more research, I am able to post a better question (though I still searching for an answer):

How do I convert a base 10 string to base 36?

Thanks

eelixduppy

2:51 am on Dec 5, 2006 (gmt 0)



I think you found your answer :)


$num = 12308912309;
$num = [url=http://us3.php.net/manual/en/function.base-convert.php]base_convert[/url]($num,10,36);
echo $num;

Jeremy_H

4:55 am on Dec 5, 2006 (gmt 0)

10+ Year Member



Thank you so much eelixduppy!

That is absolutely what I needed.

Thanks!