Re: Any similiar function to number_format????

From: Date: Thu, 21 Aug 2003 20:29:55 +0000
Subject: Re: Any similiar function to number_format????
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-160351@lists.php.net to get a copy of this message
I do that all the time and it is very helpful. I just kind of wonder if there is a php function that would do it all for me. Just got this idea when I use the number_format() and it made me wonder about whether is there such a function as this or not. (Hey Jay! Thanks for the response by the way). Scott F. "Jay Blanchard" <jay.blanchard@niicommunications.com> wrote in message news:C8F323573C030A448F3E5A2B6FE2070B0101FAD1@nemesis... [snip] 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. [/snip] Ooh, ooh, me, me! Make sure that the number is a string. $number = 1; settype($number, "string"); Test to make sure string length is 1 (becuase you don't want number like 012) if(strlen($number)== 1){ $newNumber = "0".$number; } echo"$newNumber\n";

« previous php.general (#160351) next »