Image

Imagef_it wrote in Imagephp 😯confused

Outputting text/plain using header()

I have a script with the following code:

<?
   $billetlist = "...";
   $list = file($billetlist);

   if ($_GET['view'] == "text") {
      header("Content-type: text/plain; charset=utf-8");
      foreach ($list as $num => $text) {
         $split = preg_split("/\|/", $text);
         printf("%s\t%s\n", $split[0], $split[1]);
      }
      return;
   }
?>


My question is... how can I force the header to print the output as plain text (as if it were just a text file that the user were viewing in their browser)? Right now with the code above, it is just prompting me to download the entire php file.
  1. Yes, I have already tried to google it.
  2. Yes, I have already read the PHP Manual.
  3. No, I am not a PHP Guru (nor do I claim to be one)... I'm sure my code is not the most efficient any of you have ever seen, but it works for me :)
So... anybody? Any help (or even a point in the right direction) would be greatly appreciated.