note 49249 deleted from function.fputcsv by googleguy

From: Date: Tue, 22 Oct 2013 10:14:20 +0000
Subject: note 49249 deleted from function.fputcsv by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196924@lists.php.net to get a copy of this message
Note Submitter: twebb at boisecenter dot com ---- What about cells that span multiple lines? This function allows for cells to contain newlines: <?php function fputcsv($handle, $row, $fd=',', $quot='"') { $str=''; foreach ($row as $cell) { $cell = str_replace($quot, $quot.$quot, $cell); if (strchr($cell, $fd) !== FALSE || strchr($cell, $quot) !== FALSE || strchr($cell, "\n") !== FALSE) { $str .= $quot.$cell.$quot.$fd; } else { $str .= $cell.$fd; } } fputs($handle, substr($str, 0, -1)."\n"); return strlen($str); } ?> I found this reference on the web: http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm

« previous php.notes (#196924) next »