string str_pad ( string $input
, int $pad_length
[, string $pad_string
= " " [, int $pad_type
= STR_PAD_RIGHT ]] )
$input= 來源字串
$pad_length= 要補到幾個字
$pad_string=要補什麼字
$pad_type=從哪裡開始補 1.左右都補:STR_PAD_BOTH ,2.由左邊開始補:STR_PAD_LEFT , 3.由右邊開始補:STR_PAD_RIGHT
1: //要把ID 由左邊開始補0 ,補到5位數
2: $id=01;
3: $id=str_pad($id,5,"0",STR_PAD_LEFT);
4: echo $id;
5: //00001
文章標籤
全站熱搜