JBZoo\Utils\Str::zeroPad PHP Method

zeroPad() public static method

Pads a given string with zeroes on the left.
public static zeroPad ( integer $number, integer $length ) : string
$number integer The number to pad
$length integer The total length of the desired string
return string
    public static function zeroPad($number, $length)
    {
        return str_pad($number, $length, '0', STR_PAD_LEFT);
    }

Usage Example

Example #1
0
 public function testZeroPad()
 {
     is('341', Str::zeroPad('0341', 1));
     is('341', Str::zeroPad(341, 3));
     is('0341', Str::zeroPad(341, 4));
     is('000341', Str::zeroPad(341, 6));
 }