标签: php decimal digits
我想知道如何在小数点前显示至少三位数?
例如:
$nb_badge = "001"; $nb_badge = $nb_badge+6; echo $nb_badge; // Must display "007".
答案 0 :(得分:4)
$nb_badge = sprintf("%03d", $nb_badge);