private function createTable($source, $target)
    {
        $last = count($target) - 1;
        $size = (int) log(count($source), count($target));
        $number = array_fill(0, $size, $target[0]);
        $next = array_fill(0, $size, 0);
        $limit = count($source);
        $table = [$source[0] => implode('', $number)];

        for ($i = 1; $i < $limit; $i++) {
            for ($j = $size - 1; $next[$j] === $last; $j--) {
                $number[$j] = $target[0];
                $next[$j] = 0;
            }

            $number[$j] = $target[++$next[$j]];
            $table[$source[$i]] = implode('', $number);
        }

        return $table;
    }
private function createTable($source, $target)
    {
        $last = count($target) - 1;
        $size = (int) log(count($source), count($target));
        $number = array_fill(0, $size, $target[0]);
        $next = array_fill(0, $size, 0);
        $limit = count($source);
        $table = [$source[0] => implode('', $number)];

        for ($i = 1; $i < $limit; $i++) {
            for ($j = $size - 1; $next[$j] === $last; $j--) {
                $number[$j] = $target[0];
                $next[$j] = 0;
            }

            $number[$j] = $target[++$next[$j]];
            $table[$source[$i]] = implode('', $number);
        }

        return $table;
    }
private function createTable ( $ source , $ target ) { $ last = count ( $ target ) - 1 ; $ size = ( int ) log ( count ( $ source ) , count ( $ target ) ) ; $ number = array_fill ( 0 , $ size , $ target [ 0 ] ) ; $ next = array_fill ( 0 , $ size , 0 ) ; $ limit = count ( $ source ) ; $ table = [ $ source [ 0 ] => implode ( '' , $ number ) ] ; for ( $ i = 1 ; $ i < $ limit ; $ i ++ ) { for ( $ j = $ size - 1 ; $ next [ $ j ] === $ last ; $ j -- ) { $ number [ $ j ] = $ target [ 0 ] ; $ next [ $ j ] = 0 ; } $ number [ $ j ] = $ target [ ++ $ next [ $ j ] ] ; $ table [ $ source [ $ i ] ] = implode ( '' , $ number ) ; } return $ table ; }
Creates a conversion table between two lists of digits.
@param string[] $source Digits for the number base with larger number of digits
@param string[] $target Digits for the number base with smaller number of digits
@return array<string,string> String replacement table for converting numbers
Creates a conversion table between two lists of digits .