WordPress开发者和主题制作者的搜索引擎



zeroise ›

Since0.71
已弃用n/a
zeroise ( $number, $threshold )
参数: (2)
  • (int) $number Number to append zeros to if not greater than threshold.
    Required: Yes
  • (int) $threshold Digit places number needs to be to not have zeros added.
    Required: Yes
返回:
  • (string) Adds leading zeros to number if needed.
定义在:
文档:

Add leading zeros when necessary.

If you set the threshold to '4' and the number is '10', then you will get back '0010'. If you set the threshold to '4' and the number is '5000', then you will get back '5000'.

Uses sprintf to append the amount of zeros based on the $threshold parameter and the size of the number. If the number is large enough, then no zeros will be appended.



源码

function zeroise( $number, $threshold ) {
	return sprintf( '%0' . $threshold . 's', $number );
}