Jump to content

Generate tab separted txt file.


suresh64633

Recommended Posts

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);
?>

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

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);

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.