Advertisement
Achilles

Untitled

Jun 19th, 2014
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. function convert_to_base62($n)
  2. {
  3. $base = 62;
  4. $str = "";
  5.  
  6. while ($n != 0)
  7. {
  8. $r = $n % $base;
  9. $n = (int)($n / $base);
  10.  
  11. if($r >= 10 && $r <= 35)
  12. {
  13. $str .= chr(87 + $r );
  14. }
  15.  
  16. else if($r >= 36 && $r <= 61)
  17. {
  18. $str .= chr(29 + $r);
  19. }
  20.  
  21. else
  22. {
  23. $str .= (string)$r;
  24. }
  25. }
  26.  
  27. return strrev($str);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement