function getZeroPaddedNumber($value, $padding) {
return str_pad($value, $padding, "0", STR_PAD_LEFT);
}
用法
echo getZeroPaddedNumber(123, 4);
// outputs "0123"
翻译自: https://css-tricks.com/snippets/php/zero-padded-numbers/
function getZeroPaddedNumber($value, $padding) {
return str_pad($value, $padding, "0", STR_PAD_LEFT);
}
echo getZeroPaddedNumber(123, 4);
// outputs "0123"
翻译自: https://css-tricks.com/snippets/php/zero-padded-numbers/