note 75998 modified in function.fputcsv by danbrown

From: Date: Thu, 20 Nov 2008 14:40:27 +0000
Subject: note 75998 modified in function.fputcsv by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146752@lists.php.net to get a copy of this message
Compact fputcsv function(), for Php version >= 4.0.5 and < 5.1. Not a "good programming practice", but if you need save bytes ... <?php function fputcsv($fp, $arr, $del=",", $enc="\"") { fwrite($fp, (count($arr)) ? $enc . implode("{$enc}{$del}{$enc}", str_replace("\"", "\"\"", $arr)) . $enc . "\n" : "\n"); } ?> --was-- Compact fputcsv function(), for Php version >= 4.0.5 and < 5.1. Not a "good programming practice", but if you need save bytes ... function fputcsv($fp, $arr, $del=",", $enc="\"") { fwrite($fp, (count($arr)) ? $enc . implode("{$enc}{$del}{$enc}", str_replace("\"", "\"\"", $arr)) . $enc . "\n" : "\n"); } http://php.net/manual/en/function.fputcsv.php

« previous php.notes (#146752) next »