开发者

How to get absolutely unique and five letters string using only A-Z a-z 0-9 in php? [duplicate]

开发者 https://www.devze.com 2023-04-05 10:09 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: PHP: How to generate a random, unique, alphanumeric string?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

PHP: How to generate a random, unique, alphanumeric string?

I'm creating the image hosting website. I need to create a unique and five letters string (case sensitive) for an image, like an example -> imgur.com/srM0U

I have seen many examples, but they are not unique or not case sensitive. Generated string I will use for an image filename, I think imgur uses a unique strings.

Please help with a piec开发者_开发问答e of code


http://kevin.vanzonneveld.net/techblog/article/create_short_ids_with_php_like_youtube_or_tinyurl/

The main thing to keep in mind is that the way most short-URL systems work is that they save the long form URL into a database, with an auto-incremented ID. That ID is then converted to an alphanumeric short code by a script similar to the one above.

The reason I point this out is I think you're approaching the problem backwards- trying to assign an alphanumeric shortcode first. It's much easier to have unique numeric values (hence, auto-increment) and then approach encoding it from there.

Sorry for the poor formatting, sent from my phone.

0

精彩评论

暂无评论...
验证码 换一张
取 消