I've been browsing google all day but I couldn't find a (free) script to create something exactly like IceURl. the requirements: 1. make a random generated text 2. don't use any special characters like "?" url needs to be something like this --> www.mysite.com/XOoso2 Can anyone name any?
creating a random string of 5 characters <?php $chars = "abcdefghijklmnopqrstuvwxyz1234567890"; $key = ""; for($x = 0; $x <= 4; $x++) { $key .= $chars[mt_rand(0,strlen($chars)-1)] ; } ?> PHP: it's up to you from there.
ansi, this is just a question, but does that give any better performance (or randomness) than just using str_shuffle? I used to loop it and select random characters, but I figure this'd be quicker $chars = "abcdefghijklmnopqrstuvwxyz1234567890"; $result = substr(str_shuffle($chars), 0, 10); PHP:
^^ But it would get the same ID if 2 persons want to mask the same URL. Plus it would return a 32 characters value, which is probably longer than the original URL at the end...
That might be a desired feature - it makes sense that the same target URL has the same short-URL (unless there's some specific requirement that it's different) You could cut the hash to the desired length. The chance of it being unique is obviously reduced but I'm guessing it's no more than with a random string of the same length.