note 126454 added to function.fputcsv

From: Date: Thu, 23 Sep 2021 21:52:37 +0000
Subject: note 126454 added to function.fputcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-216999@lists.php.net to get a copy of this message
In all those cases you need a bug free csv writer with custom record seperating capability: <?php /** * Custom fputcsv * @param int $handle filehandle * @param mixed[] $fields array of values to write * @param string $delimiter field delimiter * @param string $enclosure field enclosures * @param string $escape_char escape enclosure chars in fields * @param string $record_seperator * @return int characters written */ function _fputcsv($handle, $fields, $delimiter = ",", $enclosure = '"', $escape_char = "\\", $record_seperator = "\r\n") { $result = []; foreach ($fields as $field) { $result[] = $enclosure . str_replace($enclosure, $escape_char . $enclosure, $field) . $enclosure; } return fwrite($handle, implode($delimiter, $result) . $record_seperator); } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 83.97.87.182) ---- Manual Page -- https://php.net/manual/en/function.fputcsv.php Edit -- https://main.php.net/note/edit/126454 Del: integrated -- https://main.php.net/note/delete/126454/integrated Del: useless -- https://main.php.net/note/delete/126454/useless Del: bad code -- https://main.php.net/note/delete/126454/bad+code Del: spam -- https://main.php.net/note/delete/126454/spam Del: non-english -- https://main.php.net/note/delete/126454/non-english Del: in docs -- https://main.php.net/note/delete/126454/in+docs Del: other reasons-- https://main.php.net/note/delete/126454 Reject -- https://main.php.net/note/reject/126454 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216999) next »