Wellllll.... as per the example, we have an integer variable ($var) with a value of '0'. Since the crux of the original question was to display the incremented value of 0, (er, '1') with two leading zeros, '001', it's the printf() function to the rescue.
printf() has about a gazillion and three optional parameters that it will respect, and those who either read the fine print in the manual (me!) or come from a C-programming background (not me!) are familiar with the full suite of options.
Basically, in my example, I'm using printf() with the ' (padding specifier) argument. Whatever follows the ' (0, in my example) will be used to pad the value of d to the number of spaces following the '0' (3, er, the resulting string will be three characters long).
Since the variable $var needs to be incremented PRIOR to being formatted with printf(), I used ++$var instead of $var++. Had I used $var++, the resulting string would be '000'.
Hence my nifty solution to the original problem:
$var = 0;
printf("%'03d",++$var);
I bet it's all clear as mud now, huh?
To make matters even more interesting, the manual at www.php.net lists all of the 'fun shtuff' that you can do with printf() on the page for the sprintf() function...