QUOTE(DeaPeaJay @ Oct 22 2006, 02:41 AM)
I have a really simple question that I can't seem to find anywhere online cause I'm not sure what to search for.
I have an integer and I need to format it to always be three long (ie. 001). But I can't figure out how to do this in PHP.
I tried rounding it with round() like this "round(1, -3)"
but that didn't work.
I cannot imagine why or how round(1, -3) would be expected to do anything like this.
The entire C formatting functionality is available - just try sprintf() in the PHP library. IIRC, "%3d" means a 3-digit decimal number, and "%03d" means a zero-padded same.
So I think sprintf("%03d", $value) will give you what you want. (If you don't know the C 'print' family formatting stuff, it's well worth learning.)