从PHP中的一系列数字创建一系列字符

i have a database with many items in there, by the moment my users retrive info from the database using a simple php script who use GET parameters, like www.mypage.com/post.php?id=123432

Well at the beginning it was all fine, but know i have Ids that are very big (10000000). So at this point i dont my users to have that longs urls, so i think that changing the secuence of number for a secuence of leters will do the think, like post.php?id=XFBJ and then the php script knows that is the id=11223256437 for example. Any ideas of how to do this? Thanks!

I suppose you could do very simple trick to achieve that. Treat ID from URL as 36-based number and convert it to 10-based number before retrieving from database.

$_GET['id'] = '5yc1s';
$id = base_convert($_GET['id'], 36, 10); // 10000000

// SELECT ... FROM ... WHERE id = :id [id = $id]

And when you want to display a link do the opposite:

$id = 10000000;
$urlId = base_convert($id, 10, 36); // 5yc1s

// ...?id=$urlId

EDIT: Oh, base_convert() has upper limit of 36 (a-z0-9), not 32 - that makes your links even shorter. Of course you could write your own function that could convert up to 62-based numbers (a-zA-Z0-9) — that's a reasonable upper limit (of course even higher are available). Writing such a function is really easy.