<?php
#Ex: Make 4 Digit Integer Or Zerofill An Integer In PHP
// INPUT
$start_number = 1;
$end_number = 100;
for($i=$start_number; $i <= $end_number; $i++ ){
echo "<br> #: ".sprintf("%04d", $i);
}
// OUTPUT
#: 0001
#: 0002
#: 0003
#: 0004
#: 0005
#: 0006
#: 0007
#: 0008
#: 0009
#: 0010
.
.
.
#: 0100
?>
According To Question:
#add zero after number in php
#php number format: 0001, 0002, 0003 ...
#make number 2 digit php
#php leftpad number
#php force two digit number
#php sprintf
#str_pad in php
#php left fill
No comments:
Post a Comment