Jump to content

# of digits


briant

Recommended Posts

Printf is the same as sprintf so prehaps have a read of how to use [url=http://www.php.net/sprintf]sprintf[/url] function.

printf will do what you want to to do from what I can tell from your thread.
[code=php:0]// an unformated number:
$num = '523';

// now we format it, so it is a 5 digit number with
// zeros at beginning to pad the number to be five digits
$num = printf("%05d", $num);

// print our new formated number:
echo $num;
// the result should be 00523[/code]
Link to comment
https://forums.phpfreaks.com/topic/17962-of-digits/#findComment-76858
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.