Re: Send .csv file to browser [message #170038 is a reply to message #170007] |
Wed, 06 October 2010 16:25 |
Peter H. Coffin
Messages: 245 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Tue, 05 Oct 2010 11:11:24 -0400, sheldonlg wrote:
> On 10/5/2010 11:06 AM, Derek Turner wrote:
>> On Tue, 05 Oct 2010 10:55:44 -0400, sheldonlg wrote:
>>
>>> The user can then cut and paste it into a file or you can put in code
>>> for the user to download that piece.
>>>
>>> Another approach is to output an Excel file and the user can then output
>>> from that Excel file to a .csv file.
>>
>> Why not? Because it's not very elegant, is it?
>
> WGAS? Why does something have to be "elegent"? All it has to do is:
>
> 1 - Work reliably.
> 2 - Be maintainable.
>
> Besides, haven't you ever heard of K.I.S.S. or Occam's razor?
>
> (WGAS means "who gives a shit").
'cause the method fails miserably at 1.
--------------------------
$ cat foo.php
<?php
$recs = array();
$recs[] = "This is the first line.";
$recs[] = "Line the second, number 2.";
$recs[] = "Line 3, continuing.";
print_r($recs);
$line = implode(',', $recs);
print_r($line);
?>
$ php -f foo.php
Array
(
[0] => This is the first line.
[1] => Line the second, number 2.
[2] => Line 3, continuing.
)
This is the first line.,Line the second, number 2.,Line 3, continuing.$
--------------------------
How many variable columns are there in that output. Three? Five? None?
--
100. Finally, to keep my subjects permanently locked in a mindless
trance, I will provide each of them with free unlimited Internet
access.
--Peter Anspach's list of things to do as an Evil Overlord
|
|
|