You are here: Re: Number Formatting - Quick question !! « PHP Programming Language « IT news, forums, messages
Re: Number Formatting - Quick question !!

Posted by Joe Scylla on 08/24/07 07:53

jerryyang_la1@yahoo.com wrote:
> I need some advice on formatting numbers using PHP.
>
> My database holds numbers like:
>
> 10
> 0.2
>
> I need these to be displayed as
>
> 10.00
> 0.20
>

http://www.php.net/number_format

> Also some of the numbers may be negatives:
>
> -0.3
> -5
>
> Is there any easy way to detect negitives ?

<code>
if ($number < 0)
{
$color = "red";
}
else
{
$color = "green";
}
</code>

or

<code>
$color = ($number < 0) ? "red" : "green";
</code>

Joe

 

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

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