Dev-Sandbox
Posted on May 24, 2023
Requirements
Values Surrounded by Double Quotes Always.
Escape Character is "
CR+LF is the newline
function fputcsv_custom($stream, $fields, $delimiter = ",", $enclosure = '"', $escape_char = '\"', $eol = "\r\n") {
$field_arr = [];
foreach($fields as $field) {
$field_arr[] = $enclosure . stripslashes(str_replace($enclosure, $escape_char . $enclosure, $field)) . $enclosure;
}
fwrite($stream, implode($delimiter, $field_arr) . $eol);
}
Ref: https://stackoverflow.com/questions/16942531/alternative-to-fputcsv/66682050#66682050
š šŖ š
š©
Dev-Sandbox
Posted on May 24, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.