diff --git a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php index 74a56903a..6c1c3b4f4 100644 --- a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php @@ -79,6 +79,9 @@ class CsvFormatter extends AbstractFormatter // Get the field names $header = str_getcsv(array_shift($lines), $delimiter); + // Allow for replacing a null string with null/empty value + $null_replace = $this->getConfig('null'); + // Get the data $list = []; $line = null; @@ -86,6 +89,13 @@ class CsvFormatter extends AbstractFormatter foreach ($lines as $line) { if (!empty($line)) { $csv_line = str_getcsv($line, $delimiter); + + if ($null_replace) { + array_walk($csv_line, function(&$el) use ($null_replace) { + $el = str_replace($null_replace, null, $el); + }); + } + $list[] = array_combine($header, $csv_line); } }