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.
精彩评论