$value) ) { $min_value = $value; $min_text = $input; $min_base = $base; } } $min_text_len = strlen($min_text); $gmp_num = gmp_init(0); for ( $i=0; $i<$min_text_len; $i++ ) { $text = substr($min_text, 0, 1); $min_text = substr($min_text, 1); $gmp_num = gmp_mul($gmp_num, gmp_init($min_base)); $gmp_num = gmp_add($gmp_num, gmp_init(base_convert($text, $min_base, 10))); } echo gmp_strval($gmp_num).PHP_EOL; function get_base ( $string ) { $count = count_chars($string,1); $key = ord('Z'); while ( array_key_exists($key,$count) !== TRUE ) { if ( $key == ord('A') ) { $key = ord('9'); } else { $key--; } } if ( $key >= ord('A') ) { $base = $key - 54; } else if ( $key >= ord('1') ) { $base = $key - 47; } else { $base = 2; } return $base; }