note 66908 deleted from function.fgetcsv by bjori

From: Date: Thu, 01 Jun 2006 00:55:07 +0000
Subject: note 66908 deleted from function.fgetcsv by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-112697@lists.php.net to get a copy of this message
Note Submitter: Ariel asphp at dsgml dot com ---- Should you need it, here is a nice and simple function for escaping csv fields properly. This version is conditional - it only adds quotes if needed: <? function csv_escape($str) { $str = str_replace(array('"', ','), array('""', ','), $str, &$count); if($count) { return '"' . $str . '"'; } else { return $str; } } ?> This version is even simpler, but adds quotes even if not needed. <? function csv_escape($str) { return = '"' . str_replace('"','""', $str) . '"'; } ?>

« previous php.notes (#112697) next »