Hello, Use str_pad, the manual page is available at http://www.php.net/str_pad, a short example would be:
$i = 3; $i = str_pad($i, 5, "0", STR_PAD_LEFT); This function is described in the PHP manual in the string functions section, the manual is an excellent place to go first when questions such as this arise. Jason On Sun, 2003-03-09 at 14:17, Vincent M. wrote: > Hello, > > Is there an easy way to change an integer to a 5 caracters string. > For example: > $i = 3 ; > $j = 110 ; > After having changed them: > $i = "00003" ; > $j = "00110" ; > > Is there a php function to do so instead of doing this: > if( ($i>0)&&($i<10)) { > $i = "0000".$i ; > } else if( ($i>9)&&($i<100)) { > $i = "000".$i ; > } else if( ($i>99)&&($i<1000)) { > $i = "00".$i ; > } etc... > > Thanks :-) > > Vincent. -- Jason Sheets <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php