Thanks a lot. It works like a charm! -----Original Message----- From: Curt Zirzow [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 15, 2003 8:45 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Insert leading zeros
Matt Palermo <[EMAIL PROTECTED]> wrote: > I have a string of digits that looks like something like these: 0025, > 1234, 0001, 1003, and so on. They are all 4 digits in length. Then > when I increment one of them by 1, I want to still have 4 digits for the > value (it should insert the leading zeros if needed). Is there any type > of function that will force the incremented value to be exactly 4 digits > no matter what number it increments? Please let me know if there is a > function that will insert these leading zeros or truncate it to 4 digits > if necessary. Thanks. $var = sprintf("%04d", $var+1); Curt -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php