Support » Fixing WordPress » How to get a value from a .txt file and output in a page?

  • I am trying to get latest value from a txt document and show it in a page. The document is updated every 15 minutes and i need the latest value everytime i have a visitor.

    Does anybody know how to do it and if its even possible?

    The .txt document is located here:
    http://services.swpc.noaa.gov/text/wing-kp.txt

    The value i am looking for is the “1-hour predicted index”.

    I am gratefull for all the help i can get.

Viewing 1 replies (of 1 total)
  • This is a very easy thing to do in code. Which one are you more familiar with, PHP or JavaScript?

    In PHP there is the fopen and readfile functions to fetch the contents of a file:
    http://php.net/manual/en/function.readfile.php

    In JavaScript you can use the XMLHttpRequest() to fetch a file and then other commands to output it on the screen.

    Once you’ve chosen how to read the file, then the next step is to figure out what function to use to print the last line instead of the whole file.

Viewing 1 replies (of 1 total)
  • The topic ‘How to get a value from a .txt file and output in a page?’ is closed to new replies.