首页 > 代码库 > 左边用0填充补齐

左边用0填充补齐

有时候我们为了将数字对齐,好看,就在前面补0对齐

<?php
    $temp = 10000000;//8位
    $num  = 11;
    $num   = $temp+$num;
    $num  = substr($temp,6,4);//结果0011
?>

 

左边用0填充补齐