Tutorial Zero Padded Numbers

by in , 0

function getZeroPaddedNumber($value, $padding) {
       return str_pad($value, $padding, "0", STR_PAD_LEFT);
}

Usage

echo getZeroPaddedNumber(123, 4);
// outputs "0123"

Leave a Reply