File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -408,14 +408,29 @@ public function toCsv(array $header=NULL) : string {
408408 $ csvData = '' ;
409409 if (!empty ($ this ->header )) {
410410 if (!empty ($ header )) {
411- $ csvData .= implode ($ this ->delimiter , $ header ).PHP_EOL ;
411+ //Add csv enclosure
412+ if ($ this ->ignoreEnclosure === false ) {
413+ $ csvData .= $ this ->enclosure .implode ($ this ->enclosure .$ this ->delimiter .$ this ->enclosure , $ header ).$ this ->enclosure .PHP_EOL ;
414+ } else {
415+ $ csvData .= implode ($ this ->delimiter , $ header ).PHP_EOL ;
416+ }
412417 } else {
413- $ csvData .= implode ($ this ->delimiter , $ this ->header ).PHP_EOL ;
418+ //Add csv enclosure
419+ if ($ this ->ignoreEnclosure === false ) {
420+ $ csvData .= $ this ->enclosure .implode ($ this ->enclosure .$ this ->delimiter .$ this ->enclosure , $ this ->header ).$ this ->enclosure .PHP_EOL ;
421+ } else {
422+ $ csvData .= implode ($ this ->delimiter , $ this ->header ).PHP_EOL ;
423+ }
414424 }
415425 }
416426 if (!empty ($ parsedData )) {
417427 foreach ($ parsedData as $ row ) {
418- $ csvData .= implode ($ this ->delimiter , $ row ).PHP_EOL ;
428+ //Add csv enclosure
429+ if ($ this ->ignoreEnclosure === false ) {
430+ $ csvData .= $ this ->enclosure .implode ($ this ->enclosure .$ this ->delimiter .$ this ->enclosure , $ row ).$ this ->enclosure .PHP_EOL ;
431+ } else {
432+ $ csvData .= implode ($ this ->delimiter , $ row ).PHP_EOL ;
433+ }
419434 }
420435 }
421436 return $ csvData ;
You can’t perform that action at this time.
0 commit comments