/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // --------------------------------------------------------------- // Converts decimal to alphanumeric values // --------------------------------------------------------------- // 62 possibles per letter, counting from 1. // With 1 letter, 61 URLS // With 2 letters, 3,843 URLS // With 3 letters, 238,327 URLS // With 4 letters, 15,252,991 URLS // --------------------------------------------------------------- $chrs = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S' ,'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); function int_to_alph($int, $chrs) { do { $alph = $chrs[($int % $base)] . $alph; return $alph; } function alph_to_int($alph, $chrs) { { } return $int; } ?>