note 34471 added to function.number-format

From: Date: Mon, 28 Jul 2003 15:21:27 +0000
Subject: note 34471 added to function.number-format
Groups: php.notes 
Request: Send a blank email to php-notes+get-52852@lists.php.net to get a copy of this message
Ok, for those of you writing functions to zero pad, there's a reason they said to "see sprintf." Want to pad a number to 6 digits? $nMyNum = 54; $nPadLength = 6; $nPadded = sprintf("%0{$nPadLength}d", $nMyNum); And that's it. One line, no function overhead. For those of you unfamiliar with sprintf and printf, I suggest you take a look. They both offer quite a few built-in formatting elements that have been duplicated here. ---- Manual Page -- http://www.php.net/manual/en/function.number-format.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34471 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34471&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34471&report=yes

« previous php.notes (#52852) next »