PHP 8.5.0 Alpha 1 available for testing

Voting

: two plus zero?
(Example: nine)

The Note You're Voting On

johannes dot kingma at gmail dot com
3 years ago
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);
}
?>

<< Back to user notes page

To Top