Author Topic: Read in a text file  (Read 2055 times)

0 Members and 1 Guest are viewing this topic.

Offline edpnjax

  • Senior Member
  • **
  • Posts: 94
    • RiverCityWeather.Net
Read in a text file
« on: January 18, 2008, 08:33:47 PM »
I had a need with WxSim to read in a text file to an html/php page. Sounds simple.... (ok, maybe to some of you PHP guru's) problem was the text file changes with every WxSim run and contains no html tags or formatting, so just doing a simple include just turned it into one really long line. I also did not want to turn this simple task into some convoluted nightmare!

After testing this, testing that, Google'in this and that I finally came up with a simple solution to read in a raw text file and keep the text formatting. Hope it saves some time or helps out.

   echo "<pre>\n"; @readfile("./path/to/filename.txt"); echo "</pre>\n";
« Last Edit: January 18, 2008, 08:38:26 PM by edpnjax »

Weather for Jacksonville / St Johns FL
Davis VP2 Plus w/24hr FARS | Live Weather | Boltek / NexStorm | GRLevel3