WordPress 函数: zeroise

添加必要的前导零。

如果 $threshold 设置为'4',并且 $number 是是'10',返回'0010',如果 $number 是'5000',返回'5000'。

主要使用 sprintf 根据 $threshold 参数和数字本身的长度来填充前导零,如果数字本身够长,就不会有零添加。

用法

<?php zeroise( $number, $threshold ); ?>

参数

$number
(mixed) (required) 要添加前导零的数字。
Default: None

$threshold
(integer) (required) 添加前导零之后的数字的长度。
Default: None

返回值

(string)
添加前导零之后的数字。

实例

<?php
    $comments_number = get_comments_number();
    echo zeroise($comments_number, 2);
?>

修改记录

Since: 0.71

源文件

wp-includes/formatting.php