suresh64633 Posted August 25, 2009 Share Posted August 25, 2009 I want to generate Tab separated (tab delimited) txt file through PHP. Link to comment https://forums.phpfreaks.com/topic/171791-generate-tab-separted-txt-file/ Share on other sites More sharing options...
rhodesa Posted August 25, 2009 Share Posted August 25, 2009 what does your code look like so far? you will want to do something like this: <?php $fh = fopen('file.txt','w+'); while(...code for loop here...){ $row = array(); //Build an array of data fwrite($fh,implode("\t",$row).PHP_EOL); } fclose($fh); ?> Link to comment https://forums.phpfreaks.com/topic/171791-generate-tab-separted-txt-file/#findComment-905900 Share on other sites More sharing options...
kickstart Posted August 25, 2009 Share Posted August 25, 2009 Hi Also consider the fputcsv function with a parameter for the delimiter. http://uk.php.net/manual/en/function.fputcsv.php Basically you put your fields into an array and then output the array as one line using the function. All the best Keith Link to comment https://forums.phpfreaks.com/topic/171791-generate-tab-separted-txt-file/#findComment-905907 Share on other sites More sharing options...
suresh64633 Posted August 26, 2009 Author Share Posted August 26, 2009 Thanks for valuable comments. Txt files is created now i want it to be download through header() function. I try below code but it does not work. header("Location:".$fileName); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); header("Content-Disposition: attachment; filename=".$fileName); Link to comment https://forums.phpfreaks.com/topic/171791-generate-tab-separted-txt-file/#findComment-906436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.