function _strpad($input, $length, $pad = ' ', $type = STR_PAD_RIGHT) {
        $mb_length = $this->_strlen($input);
        $sb_length = strlen($input);
        $pad_length = $this->_strlen($pad);

        /* Return if we already have the length. */
        if ($mb_length >= $length) {
            return $input;
        }

        /* Shortcut for single byte strings. */
        if ($mb_length == $sb_length && $pad_length == strlen($pad)) {
            return str_pad($input, $length, $pad, $type);
        }

        switch ($type) {
            case STR_PAD_LEFT:
                $left = $length - $mb_length;
                $output = $this->_substr(str_repeat($pad, ceil($left / $pad_length)),
                        0, $left, $this->_charset) . $input;
                break;
            case STR_PAD_BOTH:
                $left = floor(($length - $mb_length) / 2);
                $right = ceil(($length - $mb_length) / 2);
                $output = $this->_substr(str_repeat($pad, ceil($left / $pad_length)),
                        0, $left, $this->_charset) .
                    $input .
                    $this->_substr(str_repeat($pad, ceil($right / $pad_length)),
                        0, $right, $this->_charset);
                break;
            case STR_PAD_RIGHT:
                $right = $length - $mb_length;
                $output = $input .
                    $this->_substr(str_repeat($pad, ceil($right / $pad_length)),
                        0, $right, $this->_charset);
                break;
        }

        return $output;
    }
function _strpad($input, $length, $pad = ' ', $type = STR_PAD_RIGHT) {
        $mb_length = $this->_strlen($input);
        $sb_length = strlen($input);
        $pad_length = $this->_strlen($pad);

        /* Return if we already have the length. */
        if ($mb_length >= $length) {
            return $input;
        }

        /* Shortcut for single byte strings. */
        if ($mb_length == $sb_length && $pad_length == strlen($pad)) {
            return str_pad($input, $length, $pad, $type);
        }

        switch ($type) {
            case STR_PAD_LEFT:
                $left = $length - $mb_length;
                $output = $this->_substr(str_repeat($pad, ceil($left / $pad_length)),
                        0, $left, $this->_charset) . $input;
                break;
            case STR_PAD_BOTH:
                $left = floor(($length - $mb_length) / 2);
                $right = ceil(($length - $mb_length) / 2);
                $output = $this->_substr(str_repeat($pad, ceil($left / $pad_length)),
                        0, $left, $this->_charset) .
                    $input .
                    $this->_substr(str_repeat($pad, ceil($right / $pad_length)),
                        0, $right, $this->_charset);
                break;
            case STR_PAD_RIGHT:
                $right = $length - $mb_length;
                $output = $input .
                    $this->_substr(str_repeat($pad, ceil($right / $pad_length)),
                        0, $right, $this->_charset);
                break;
        }

        return $output;
    }
function _strpad ( $ input , $ length , $ pad = ' ' , $ type = STR_PAD_RIGHT ) { $ mb_length = $ this -> _strlen ( $ input ) ; $ sb_length = strlen ( $ input ) ; $ pad_length = $ this -> _strlen ( $ pad ) ; /* Return if we already have the length. */ if ( $ mb_length >= $ length ) { return $ input ; } /* Shortcut for single byte strings. */ if ( $ mb_length == $ sb_length && $ pad_length == strlen ( $ pad ) ) { return str_pad ( $ input , $ length , $ pad , $ type ) ; } switch ( $ type ) { case STR_PAD_LEFT : $ left = $ length - $ mb_length ; $ output = $ this -> _substr ( str_repeat ( $ pad , ceil ( $ left / $ pad_length ) ) , 0 , $ left , $ this -> _charset ) . $ input ; break ; case STR_PAD_BOTH : $ left = floor ( ( $ length - $ mb_length ) / 2 ) ; $ right = ceil ( ( $ length - $ mb_length ) / 2 ) ; $ output = $ this -> _substr ( str_repeat ( $ pad , ceil ( $ left / $ pad_length ) ) , 0 , $ left , $ this -> _charset ) . $ input . $ this -> _substr ( str_repeat ( $ pad , ceil ( $ right / $ pad_length ) ) , 0 , $ right , $ this -> _charset ) ; break ; case STR_PAD_RIGHT : $ right = $ length - $ mb_length ; $ output = $ input . $ this -> _substr ( str_repeat ( $ pad , ceil ( $ right / $ pad_length ) ) , 0 , $ right , $ this -> _charset ) ; break ; } return $ output ; }
Returns a string padded to a certain length with another string.

This method behaves exactly like str_pad but is multibyte safe.

@param string $input The string to be padded.
@param integer $length The length of the resulting string.
@param string $pad The string to pad the input string with. Must
be in the same charset like the input string.
@param const $type The padding type. One of STR_PAD_LEFT,
STR_PAD_RIGHT, or STR_PAD_BOTH.

@return string  The padded string.
Returns a string padded to a certain length with another string .