OVH Community, votre nouvel espace communautaire.

OVH CentOS 6.5 (CSV FILE AND LINE BREAKING)


Daniel60
25/03/2015, 07h59
+1
Je parie que le SE local est Windows

fritz2cat
24/03/2015, 21h54
Citation Envoyé par altissio
During a csv export...

..
//--Boucle foreach
...
fputcsv($fichier_csv,$donnee,";");
fichier_csv, donnee, boucle -> c'est du français tout ça,
alors pourquoi poster en anglais dans un forum où la langue d'échange est le français ?

altissio
24/03/2015, 16h07
During a csv export locally on wamp (php 5.5.12) , my csv file has line breaks. In production (VPS Cloud on OVH, Plesk with CentOS 6.5, php 5.3.3) , line breaks are replaced by spaces. I use the php method fputcsv . On local PHP_EOL constant is a line break, on production, it is a space. If I use a manual method with \r\n the result is the same. I don't understand !

Have you got an idea ?

$filename = dirname(__FILE__).'/../../../../../data/export.csv';
$fichier_csv = fopen($filename, 'w+');
//--Boucle foreach
foreach ($data as $donnee) {
foreach($donnee as &$champ) {
$champ = (is_string($champ)) ?
iconv("UTF-8", "Windows-1252//TRANSLIT", $champ) : $champ;
}
fputcsv($fichier_csv,$donnee,";");


}
Thanks.