Re: [PHP] Get rid of da Zero's

2001-01-26 Thread Christian Reiniger

On Thursday 25 January 2001 23:27, Ethan Nelson wrote:

 It needs to quit shaving zero's when it hits the decimal point.

 40.00 into 40
 45.50 into 45.5
 40.25 into 40.25

Hmm,
$ValWithoutZ = (double) $ValWithZ;

should work fine (i.e. interpreting the number as floating-point value 
instead of as string)

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

"use the source, luke." (obi-wan gnuobi)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Get rid of da Zero's

2001-01-25 Thread Ethan Nelson

Almost there... actually this creates one problem...

It turns 40.00 into 4

It needs to quit shaving zero's when it hits the decimal point.

40.00 into 40
45.50 into 45.5
40.25 into 40.25

Thanks

-Original Message-
From: Philip Hallstrom [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 25, 2001 12:43 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Question about dopping zeros


ereg_replace("[0\.]*$", "", $number)

should do it.  I'm not sure you need the slash in front of the dot or
not. try it and see.

In article
[EMAIL PROTECTED] you
write:
I need to format decimals that are percise to the second place in the
following format:

4.00 to 4
4.50 to 4.5
4.25 to 4.25

As you can see, I just want to drop the trailing zeros, and if necessary
the
decimal.

Thanks

___
Ethan Nelson, Systems Administrator
Net Solutions, LLC
840 Lawrence Street
Eugene, OR 97401
[EMAIL PROTECTED]
http://www.netsolutionsllc.com
Voice +1 541 345-7087
Fax   +1 541 485-5519


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]