final public function toArbitraryBase(string $number, string $alphabet, int $base) : string
    {
        if ($number === '0') {
            return $alphabet[0];
        }

        $base = (string) $base;
        $result = '';

        while ($number !== '0') {
            [$number, $remainder] = $this->divQR($number, $base);
            $remainder = (int) $remainder;

            $result .= $alphabet[$remainder];
        }

        return \strrev($result);
    }
final public function toArbitraryBase(string $number, string $alphabet, int $base) : string
    {
        if ($number === '0') {
            return $alphabet[0];
        }

        $base = (string) $base;
        $result = '';

        while ($number !== '0') {
            [$number, $remainder] = $this->divQR($number, $base);
            $remainder = (int) $remainder;

            $result .= $alphabet[$remainder];
        }

        return \strrev($result);
    }
final public function toArbitraryBase ( string $ number , string $ alphabet , int $ base ) : string { if ( $ number === '0' ) { return $ alphabet [ 0 ] ; } $ base = ( string ) $ base ; $ result = '' ; while ( $ number !== '0' ) { [ $ number , $ remainder ] = $ this -> divQR ( $ number , $ base ) ; $ remainder = ( int ) $ remainder ; $ result .= $ alphabet [ $ remainder ] ; } return \ strrev ( $ result ) ; }
Converts a non-negative number to an arbitrary base using a custom alphabet.

@param string $number   The number to convert, positive or zero, following the Calculator conventions.
@param string $alphabet The alphabet that contains every digit, validated as 2 chars minimum.
@param int    $base     The base to convert to, validated from 2 to alphabet length.

@return string The converted number in the given alphabet.
Converts a non - negative number to an arbitrary base using a custom alphabet .