note 47547 added to function.fputcsv

From: Date: Fri, 19 Nov 2004 17:56:10 +0000
Subject: note 47547 added to function.fputcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-80773@lists.php.net to get a copy of this message
The function in the prior comment doesn't escape quotes in fields, here mine: function fputcsv($handle, $row, $fd=',', $quot='"') { $str=''; foreach ($row as $cell) { str_replace(Array($quot, "\n"), Array($quot.$quot, ''), $cell); if (strchr($cell, $fd)) { $str.=$quot.$cell.$quot.$fd.' '; } else { $str.=$cell.$fd.' '; } } fputs($handle, substr($str, 0, -2)."\n"); return $str-1; } ---- Manual Page -- http://www.php.net/manual/en/function.fputcsv.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47547 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47547&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47547&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47547&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47547&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47547&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47547&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47547&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80773) next »