Jump to content

sprintf() issues


Nodral

Recommended Posts

Hi

 

I have a series of numbers which I am putting into an array, however I need them all to be 5 digits long.  I want to pad out the left side of the shorter ones with zeroes and the easiest way to do this should be sprintf().

 

However, I've been reading and rereading various tutorials and manuals (inc php.net) and don't really understand how to achieve this.

 

I thought it would be $formatted=sprintf("%05s", $unformatted);  however this doesn't work.

 

Hopefully a php guru or just someone who understands it can give me a quick repsonse to this.

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/239636-sprintf-issues/
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.