Re: Array to csv or excel in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19 April 2010 17:00, Andrew Ballard <aballard@xxxxxxxxx> wrote:
> On Mon, Apr 19, 2010 at 9:45 AM, Manolis Vlachakis
> <vlachakis.manolis@xxxxxxxxx> wrote:
>> hallo there everyone..
>> i got an array from my database
>> Help with Code Tags<http://www.daniweb.com/forums/misc-explaincode.html?TB_iframe=true&height=400&width=680>
>> *PHP Syntax* (Toggle Plain Text<http://www.daniweb.com/forums/post1194347.html#>
>> )
>>
>>
>>   1. $save=split("[|;]",$listOfItems);
>>
>>
>> and what i want i s after making some changes to the attributes on the array
>> above to export them on an csv or excel format
>> but directly as a message to the browser ..
>> i dont want it to be saved on the server ...
>> what i cant understand from the examples i found on the net ..
>> is how to handle the files and which are created cause
>> i just have the array in a php file nothing more...
>>
>>
>> another thing i have in mind is to export from the ldap server the files
>> directly but seems to me as the wrong way to do it
>>
>> thanks
>>
>
> Often when outputting csv, I usually do something like this:
>
> <?php
>
> $fp = fopen('php://output', 'w') or die('Could not open stream');
>
> foreach ($data as $row) {
>    // Assumes that $row will be an array.
>    // Manipulate the data in $row if necessary.
>    fputcsv($fp, $row);
> }
>
> ?>

An interesting idea. I'd do:

echo implode(',', $row);

regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux