You are here: Re: decimal formatting « All PHP « IT news, forums, messages
Re: decimal formatting

Posted by ED on 09/13/06 13:11

"Koncept" <user@unknown.invalid> wrote in message
news:110920062049520846%user@unknown.invalid...
> In article <ee49ue0d0o@drn.newsguy.com>, Tim <tim@aol.net> wrote:
>
>> You could use printf|sprintf and assign it to whatever variable you
>> needed it
>> for. As an example, maybe...
>>
>> $rounded_no = sprintf("%.2f", $fp_no);
>
> Yep. sprintf is what you are looking for. It returns a formatted value
> but does not print like printf. Tim's example will work just fine for
> you.
>
> --
> Koncept <<
> "The snake that cannot shed its skin perishes. So do the spirits who are
> prevented from changing their opinions; they cease to be a
> pirit." -Nietzsche

Or for yet another alternative use number_format:

$rounded = number_format($number, 2, '.', '');

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация