Wednesday, 4 January 2017

FIll Zeroes before the Number in PHP


 function zerofill ($num, $zerofill = 10) {
                        return str_pad($num, $zerofill, '0', STR_PAD_LEFT);

}
                   
                    

 echo  zerofill (2,5);

output: 00002

in zerofill function, just put the number in the first parameter, and in the second parameter, just add the number of zeros to be fill.

No comments:

Post a Comment