You are here: How do I format this floating point number in a line? « PHP Programming Language « IT news, forums, messages
How do I format this floating point number in a line?

Posted by laredotornado@zipmail.com on 03/20/06 21:30

Hi,

I am grabbing prices from a database. Sometimes the price is NULL and
sometimes there's a floating point value. Using PHP 4, when I print
the price to my CSV file, I want the price, rounded to the second
decimal place if the pirce is non-empty, but nothing if the price was
empty.

This doesn't work (it prints out 0.00 if the price is empty), but right
now I have

$line =
sprintf("\"%s\",\"%s\",\"%s\",\"%s\",\$%2.2f,\$%2.2f,\"%s\",%d,\"%s\"\r\n",
$company,
$model_num,
$box_name,
$compatible_models,
$retail_price,
$price,
$description,
$max_yield,
$color);

How do I adjust the above to get my desired result?

Thanks, -

 

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

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