public static function baseToDec($input, $Chars)
    {
        if (preg_match('/^[' . $Chars . ']+$/', $input)){
            $Result = (string)'0';

            for ($i=0; $i<strlen($input); $i++){
                if ($i != 0) $Result = bcmul($Result, strlen($Chars),0);
                $Result = bcadd($Result, strpos($Chars, $input[$i]),0);
            }
            return $Result;
        }
        return false;
    }
public static function baseToDec($input, $Chars)
    {
        if (preg_match('/^[' . $Chars . ']+$/', $input)){
            $Result = (string)'0';

            for ($i=0; $i<strlen($input); $i++){
                if ($i != 0) $Result = bcmul($Result, strlen($Chars),0);
                $Result = bcadd($Result, strpos($Chars, $input[$i]),0);
            }
            return $Result;
        }
        return false;
    }
public static function baseToDec ( $ input , $ Chars ) { if ( preg_match ( '/^[' . $ Chars . ']+$/' , $ input ) ) { $ Result = ( string ) '0' ; for ( $ i = 0 ; $ i < strlen ( $ input ) ; $ i ++ ) { if ( $ i != 0 ) $ Result = bcmul ( $ Result , strlen ( $ Chars ) , 0 ) ; $ Result = bcadd ( $ Result , strpos ( $ Chars , $ input [ $ i ] ) , 0 ) ; } return $ Result ; } return false ; }
convert character string with arbitrary base to decimal string
@param string $input       arbitrary base string
@param string $Chars       list of letters in arbitrary base
@return string             decimal base string
convert character string with arbitrary base to decimal string