I am using fputcsv function to write data in a file.But it is removing the trailing zeros from the output. Here is the code I am using
foreach($invoice_hdr_array as $csv_response)
{
fputcsv($fh1, $csv_response, ',', '"');
}
If you observe the end of the line it should be 0.00. But I am getting as only 0.
In out put I am getting like this
LIN,1,1234567890123,EN,,,1.00,94.00,94.00,0
But this should be like below
LIN,1,1234567890123,EN,,,1.00,94.00,94.00,0.00
Any help would be greatly appreciated. Thank you.
If I test your input, and leave numbers as numbers, I get:
Observe how all whole numbers loose their zero's, which is not what you get. Your question seems inaccurate? The only reason, I can think of, why you get
94.00, is when it is a string. To illustrate this point I created this code:And the output is:
So I see 2 solutions:
fputcsv(), but make your own version.And finally, do I need to point out that
0is, numerically, the same as0.00?