fork download
  1. <?php
  2.  
  3. function toBase($num, $b=62) {
  4. $base='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  5. $r = $num % $b ;
  6. $res = $base[$r];
  7. $q = floor($num/$b);
  8. while ($q) {
  9. $r = $q % $b;
  10. $q =floor($q/$b);
  11. $res = $base[$r].$res;
  12. }
  13. return $res;
  14. }
  15.  
  16. function toTen( $num, $b=62) {
  17. $base='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  18. $limit = strlen($num);
  19. $res=strpos($base,$num[0]);
  20. for($i=1;$i<$limit;$i++) {
  21. $res = $b * $res + strpos($base,$num[$i]);
  22. }
  23. return $res;
  24. }
  25.  
  26. echo toBase('79268757439');
  27.  
  28. echo '<br>'.PHP_EOL;
  29.  
  30. echo toTen('1owzCVN');
Success #stdin #stdout 0.03s 26292KB
stdin
Standard input is empty
stdout
1owzCVN<br>
79268757439