At 22:23 9-3-2003, you wrote:
You're looking for the str_pad function.
http://www.php.net/str_pad

$i = 3;
$i = str_pad($i, 5, '0', STR_PAD_LEFT);
echo $i;  // outputs '00003'

Just keep in mind that it won't help you if your input is greater than 5
to begin with, you'll have to check that seperately.

You can also have a look at http://nl.php.net/manual/en/function.sprintf.php


Example 5. sprintf(): zero-padded integers
$isodate = sprintf("%04d-%02d-%02d", $year, $month, $day);


if it is only for output, have a look at http://nl.php.net/manual/en/function.printf.php



-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to