RE: [PHP] Any similiar function to number_format????

From: Date: Thu, 21 Aug 2003 20:24:35 +0000
Subject: RE: [PHP] Any similiar function to number_format????
Groups: php.general 
Request: Send a blank email to php-general+get-160345@lists.php.net to get a copy of this message
And now to send my response to the entire list. -- Scott Fletcher <mailto:scott@abcoa.com> on Thursday, August 21, 2003 1:12 PM said: > Wondering if there is any similiar function to a php > number_format(). This time, without a period. For example, if I get > a '1', I would like to format it to be '01' in two digit. Don't know about that but you could easily make your own. <? function numberFormatPartDeux($number, $digits) { $numberCount = count($number); $padNeeded = ($digits-$numberCount)+1; $string = str_pad($number, $padNeeded, "0", STR_PAD_LEFT); return $string; } $number = 10; $digits = 3; echo numberFormatPartDeux($number,$digits); ?> Or I guess I could make one for you. Chris.

« previous php.general (#160345) next »