src/Utilities/Miscellaneous.php
public static function fillMissingZeros($number, $length, $before = true)
    {
        /*
         * It's not a number? Empty string is not a number too.
         * Nothing to do
         */
        if (!is_numeric($number)) {
            return '';
        }

        $text = trim($number);
        $textLength = mb_strlen($text);

        if ($length <= $textLength) {
            return $text;
        }

        for ($i = ($length - $textLength); 0 < $i; --$i) {
            if ($before) {
                $text = '0' . $text;

                continue;
            }

            $text .= '0';
        }

        return $text;
    }
public static function fillMissingZeros($number, $length, $before = true)
    {
        /*
         * It's not a number? Empty string is not a number too.
         * Nothing to do
         */
        if (!is_numeric($number)) {
            return '';
        }

        $text = trim($number);
        $textLength = mb_strlen($text);

        if ($length <= $textLength) {
            return $text;
        }

        for ($i = ($length - $textLength); 0 < $i; --$i) {
            if ($before) {
                $text = '0' . $text;

                continue;
            }

            $text .= '0';
        }

        return $text;
    }
public static function fillMissingZeros ( $ number , $ length , $ before = true ) { /*
         * It's not a number? Empty string is not a number too.
         * Nothing to do
         */ if ( ! is_numeric ( $ number ) ) { return '' ; } $ text = trim ( $ number ) ; $ textLength = mb_strlen ( $ text ) ; if ( $ length <= $ textLength ) { return $ text ; } for ( $ i = ( $ length - $ textLength ) ; 0 < $ i ; -- $ i ) { if ( $ before ) { $ text = '0' . $ text ; continue ; } $ text .= '0' ; } return $ text ; }
Adds missing the "0" characters to given number until given length is reached

Example:
- number: 201
- length: 6
- will be returned: 000201

If "before" parameter is false, zeros will be inserted after given number. If given number is longer than
given length the number will be returned as it was given to the method.

@param mixed $number Number for who the "0" characters should be inserted
@param int   $length Wanted length of final number
@param bool  $before (optional) If false, 0 characters will be inserted after given number
@return string
Adds missing the 0 characters to given number until given length is reached