如何在小数点前显示三位数?

时间:2016-04-05 23:36:02

标签: php decimal digits

我想知道如何在小数点前显示至少三位数?

例如:

$nb_badge = "001";
$nb_badge = $nb_badge+6;
echo $nb_badge; // Must display "007".

1 个答案:

答案 0 :(得分:4)

$nb_badge = sprintf("%03d", $nb_badge);