必要时添加前导零。
原型
zeroise( int $number, int $threshold )
描述
如果你将阈值设置为“4”且数字为“10”,那么你将返回“0010”。如果你将阈值设置为“4”且数字为“5000”,那么你将返回“5000”。
参数
$number
(int)
(Required)
如果不大于阈值,则将零附加到的数字。
$threshold
(int)
(Required)
数字位数需要不添加零。
返回值
(string)
如果需要,将前导零添加到数字。
源文件
路径:wp-includes/formatting.php
<?php
...
function zeroise( $number, $threshold ) {
return sprintf( '%0' . $threshold . 's', $number );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/zeroise/