note 115556 added to function.fgetcsv

From: Date: Fri, 15 Aug 2014 07:10:20 +0000
Subject: note 115556 added to function.fgetcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-200192@lists.php.net to get a copy of this message
The problem with \" character sequence appears when blackslash is treated as an escape character, so it parses the characters \" as a backslash-escaped double quote. The fix this (PHP 5.3.0+): we need to tell fgetcsv() not to use backslash as an escape character by passing other character as the $escape parameter to it. Unfortunately, passing null, false or '' (empty string) don't work. For me it worked when passed the same character as $enclosure (double quote for example) '"': <?php $handle = fopen('file.csv', 'r'); $row = fgetcsv($handle, null, ";", '"', '"'); // Disable escape character print_r($row); fclose($handle); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 176.37.151.34 ---- Manual Page -- http://php.net/manual/en/function.fgetcsv.php Edit -- https://master.php.net/note/edit/115556 Del: integrated -- https://master.php.net/note/delete/115556/integrated Del: useless -- https://master.php.net/note/delete/115556/useless Del: bad code -- https://master.php.net/note/delete/115556/bad+code Del: spam -- https://master.php.net/note/delete/115556/spam Del: non-english -- https://master.php.net/note/delete/115556/non-english Del: in docs -- https://master.php.net/note/delete/115556/in+docs Del: other reasons-- https://master.php.net/note/delete/115556 Reject -- https://master.php.net/note/reject/115556 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200192) next »