Re: CSV output.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm guessing that when you are writing your values, you are writing
numbers to the file and not strings. With numbers, the significant
floating-point values are obviously preserved, but a number like 12.00
will be written as just 12. Try either casting the value to a string, or
having PHP auto-cast by doing something like this:

fwrite($fh, "$price");

The double quotes forces PHP to convert the number to a string.


Ash
www.ashleysheridan.co.uk
--- Begin Message ---
Tom Shaw wrote:
> I'm outputting a bunch of numerical values for a spreadsheet to calculate
> total sales among other things on a client shopping cart. I'm running into
> problems with values that contain zeros after the decimal. If a value is
> 234.55 the value outputs fine to the CSV file but if the value is 234.00
> only 234 shows up. Is there any way to force the zeros into the spreadsheet?

If your code is written correctly, the .00 will be in the CSV file

However the program you are using to view the CSV file probably
auto-hides them without you knowing it.

POST YOUR Code
POST your CSV output

Without Code and without Output, you don't really show the problem.

Wolf


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux