I would like to have a function to generate numbers starting from “000100”.
Right now I have the following function that allows me to generate numbers with leading zeros.
How can I modify it in order to fit my needs?
function lz( $aNumber, $intPart, $floatPart=NULL, $dec_point=NULL, $thousands_sep=NULL)
{
$formattedNumber = $aNumber;
if (!is_null($floatPart))
{
$formattedNumber = number_format($formattedNumber, $floatPart, $dec_point, $thousands_sep);
}
$formattedNumber = str_repeat("0",($intPart + -1 - floor(log10($formattedNumber)))).$formattedNumber;
return $formattedNumber;
}
Example: A new order has been placed and the order id is “19”. The final order number must be 000119.
Thanks!
Why not use a single
printfas:See it
The format specifier used is:
EDIT:
From your edit looks like you want to add 100 to the input before formatting it. If so you can do: