fork download
  1. <?php
  2. function baseToDec($val){
  3. $baseStr = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  4. $n = strlen($val);
  5. $b = strlen($baseStr);
  6. $s = 0;
  7. // var_dump($n);
  8. for ($i =0; $i < strlen($val); $i++){
  9. $n--;
  10. $s = $s + (strpos($baseStr,$val[$i])*($b**$n));
  11. // The non numerical values, such as E or Q could
  12. // not be multiplied, so we used its index in the $baseStr
  13. }
  14. return $s;
  15. }
  16. echo baseToDec('A11320');
Success #stdin #stdout 0.02s 23452KB
stdin
Standard input is empty
stdout
606391992