I don't know this question is asked or not. I didn't get his in suggestion.
I'm trying to write some data from database to an csv file.
I'm using fputcsv function.
I'm using following code :
$fh = @fopen($fileName, 'w+');
$writeText['sku'] = $somevalue
$writeText['attribute_set'] = $somevalue
$writeText['type'] = $somevalue
$writeText['default_catalogue_link']= $somevalue
$writeText['status'] = $somevalue
@fputcsv($fh, $writeText);
@flush();
@fclose($fh);
Some of the values starts with zero like $writeText['sku'] is 0987.
After writing to the file. I'm getting 987 in the file.
how to prevent this? I need with zero values.
Any help would be usefull. Thanks in advance.
$writeText['sku'] = (string)$somevalue;str_pad()to maintain a leading zero. Or I believe if you ensure that the values are encapsulated as strings (with quotes) in the CSV they should keep the leading zeros.$writeText['sku'] = " ".$somevalue;also, its not working. I'm not getting how to encapsulate with qoutes :-(