I want to print a list of numbers in php.
But I want to print 4 digits of numbers (preceding with zero if necessary), eg
0001, 0009, 0076, 0129, 1234
What should I do?
printf("%04d", $num);
printf ('%04d' ,$num)
Look at the PHP Language Reference Manual and search for zero-padded integers
The link gives the sprintf
details, but the format string information applies to related functions like printf
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.