Tobin Thomas Tobin Thomas - 5 months ago 25
PHP Question

how to put a space after decimal value in csv using fputcsv?

enter image description here

This is the code i have used to write data into csv file.
Everything is working fine except decimal values!

$row[] = '14.31 ';
fputcsv($fp, $row, ',', '"');

i have a space after .31
"14.31 "
so length should be
and now i am getting

how to include this space in the cell?

Answer Source

Assign the value to a variable and convert to string Eg : $test ='14. 31 '; $row[] =(string) $test;

Or use double quotes Eg: $test = "14.31" ;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download