On Tuesday 25 September 2001 19:38, Evan Nemerson wrote:
> Yeah, but what if they don't JUST want to print it...
>
> /*untested*/
> $i=524;
> $n=5-strlen($i);
> $outnum="";
> for($x=1;$x<=$n;$x++){
> $outnum.="0";
> };
> $outnum.=$i;
$outnum = sprintf('%05d' , 524);
--
Meir Kriheli
> On T
<[EMAIL PROTECTED]>
> Sent: Tuesday, September 25, 2001 9:41 AM
> Subject: Re: [PHP] 2 decimal places
>
> > At 22:22 19/09/01 -0400, Kurth Bemis wrote:
> > >i'm looking for a php function to add 2 decimal place sto a number. if
> > >the number already have
> Yeah, but what if they don't JUST want to print it...
Umm, have you read the documentation on either of
the functions? They both return a string; they don't
send anything to standard out (like echo or print does).
$myString = printf();
$myString = sprintf();
echo $myString;
Chris
Yeah, but what if they don't JUST want to print it...
/*untested*/
$i=524;
$n=5-strlen($i);
$outnum="";
for($x=1;$x<=$n;$x++){
$outnum.="0";
};
$outnum.=$i;
On Tuesday 25 September 2001 09:56, you wrote:
> > What if I want to pad a number with zeros in the other
> > direction? I.E:
> >
> What if I want to pad a number with zeros in the other
> direction? I.E:
> 524 becomes 00524
printf() / sprintf() is your friend.
Chris
What if I want to pad a number with zeros in the other direction? I.E:
524 becomes 00524
- Original Message -
From: "Christian Dechery" <[EMAIL PROTECTED]>
To: "Kurth Bemis" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, September
At 22:22 19/09/01 -0400, Kurth Bemis wrote:
>i'm looking for a php function to add 2 decimal place sto a number. if
>the number already have one decimal place then one more zero should be
>added to make it two decimal placesanyone know of a quick way to do this?
$number=32.5;
echo number_
number_format($variable, 2, '.', '')
something like that i believe
- Original Message -
From: "Kurth Bemis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 19, 2001 7:22 PM
Subject: [PHP] 2 decimal places
> i'm looking for a php function to add 2 decimal place st
At 10:24 PM 9/19/2001, Jack Dempsey wrote:
Thank You!
>look into printf and number_format
>
>-Original Message-
>From: Kurth Bemis [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, September 19, 2001 10:23 PM
>To: [EMAIL PROTECTED]
>Subject: [PHP] 2 decimal places
>
>
>i'm looking for a php f
look into printf and number_format
-Original Message-
From: Kurth Bemis [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 19, 2001 10:23 PM
To: [EMAIL PROTECTED]
Subject: [PHP] 2 decimal places
i'm looking for a php function to add 2 decimal place sto a number. if the
number alread
10 matches
Mail list logo