<?php
  function baseToDec($val){
    $baseStr = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $n = strlen($val);
    $b = strlen($baseStr);
    $s = 0;
   // var_dump($n);
    for ($i =0; $i < strlen($val); $i++){
      $n--;
      $s = $s + (strpos($baseStr,$val[$i])*($b**$n)); 
        // The non numerical values, such as E or Q could
       // not be multiplied, so we used its index in the $baseStr
    }
    return $s;
  }
  echo baseToDec('A11320');