P粉0566180532023-08-24 12:34:35
Assume the value is in $value:
Echo it:
printf(" d", $value);
Get it:
$formatted_value = sprintf(" d", $value);
This should do the trick
P粉0186537512023-08-24 10:30:07
Usesprintf
: p>
sprintf('%08d', 1234567);
Alternatively, you can use str_pad
< /a>:
str_pad($value, 8, '0', STR_PAD_LEFT);