Alexander Foken: anführende null bei zahlen

Beitrag lesen

Moin Moin !

wenn du immer weißt, wieviele nullen du brauchst:

var neue_zahl = ('00' + alte_zahl).substr(0, 2);

Damit fällst Du bei 10 auf die Nase:

'00' + 10 => '0010'

'0010'.substr(0,2) => '001'

Alexander <-- froh, daß meine Lieblingssprache printf("%02i",integer) kann ...

--
Nein, ich beantworte keine Fragen per eMail. Dafür ist das Forum da.
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so!"
Mein "Lieblings-Forums-Bug": http://cforum.teamone.de/phpbt/bug.php?op=show&bugid=103&pos=2