 Site Admin
Joined: 10 Dec 2007 Posts: 143 Location: New Zealand
|
Sometimes you'll need add zeros (0000) in front of some integers such as invoice number followed by certain numbering rules - zero fill - to make it look better on invoices / quotations / etc.
PHP does not natively support zerofill functions but the following customer function will let you use zero fill function with a few lines of codes:
| Code: | <?php
function zero_fill($number,$padding)
{
return str_pad($number, $padding, "0", STR_PAD_LEFT);
}
echo zero_fill(3123,10);
?> |
From echo zero_fill(3123,10);, 3123 is actual integer you want to display, 10 is the number of digits (paddings) you want to display. _________________ Paul KH Kim
http://www.onlinesolution.co.nz |
|