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('792fdsfds439');
  27.  
  28. echo '<br>'.PHP_EOL;
  29.  
  30. echo toTen('1owzCVN');
Success #stdin #stdout #stderr 0.02s 25672KB
stdin
Standard input is empty
stdout
cM<br>
79268757439
stderr
PHP Notice:  A non well formed numeric value encountered in /home/jarTLK/prog.php on line 5
PHP Notice:  A non well formed numeric value encountered in /home/jarTLK/prog.php on line 7