Re: Get rid of da Zero's
| From: | Art Wells | Date: | Fri, 26 Jan 2001 16:24:19 +0000 |
| Subject: | Re: Get rid of da Zero's | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36775@lists.php.net to get a copy of this message | ||
preg_replace("/0+$/","",$number);
On Thu, 25 Jan 2001, Ethan Nelson wrote:
> 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:philip@oddjob.adhesivemedia.com]
> Sent: Thursday, January 25, 2001 12:43 PM
> To: enelson@netsolutionsllc.com
> 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
> <A82752B9656BD411AEE7005004632486018EFA@voyager.netsolutionsllc.com> 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
> >enelson@netsolutionsllc.com
> >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: php-general-unsubscribe@lists.php.net
> >For additional commands, e-mail: php-general-help@lists.php.net
> >To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
--
http://www.artwells.com/
That which indicates nothing
introduces everything.