FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Send .csv file to browser
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Send .csv file to browser [message #170044 is a reply to message #170039] Thu, 07 October 2010 02:55 Go to previous messageGo to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma:
Senior Member
On Wed, 06 Oct 2010 12:28:30 -0400, Jerry Stuckle wrote:
> On 10/6/2010 12:25 PM, Peter H. Coffin wrote:
>> On Tue, 05 Oct 2010 11:11:24 -0400, sheldonlg wrote:
>>>
>>> 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?
>>
> Which has the same problem as Sheldon's - parsing the .csv will give:
>
> This is the first line.
> Line the second
> number 2
> Line 3
> continuing.

Exactly. implode()ing with commas makes suck-tastic CSV. fputcsv() is
not perfect, but it's a hell of a lot better, and (combining with clever
file handles like $fh = fopen("php://output", 'w'); ) doesn't take all
that much more code to implement.

--
72. If all the heroes are standing together around a strange device and
begin to taunt me, I will pull out a conventional weapon instead of
using my unstoppable superweapon on them.
--Peter Anspach's list of things to do as an Evil Overlord
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: file access permission?
Next Topic: Process queue without cron jobs
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Feb 18 19:59:13 GMT 2025

Total time taken to generate the page: 0.05581 seconds