Results 1 to 3 of 3

Thread: scanning a .txt webpage and converting to a variable.

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default scanning a .txt webpage and converting to a variable.

    How could I create a form where I enter in the url of a txt document, which would then retrieve the text from that document and save it as a string to be manipulated for my own diabolical plans?

    Sort of like how W3C scans a web page for errors, except that I have different plans. The format would be simple like $text="everything from selected www.a_site.txt"

    I can create a form and manipulate the data, but getting it from a submitted url is where I am unsure.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Well, you could use fopen() or file_get_contents(), but this requires that your server has "allow_url_fopen" set in the php.ini file. If you cannot use those options, then you will have to use fsockopen() and do it the old fashioned way.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Took me a bit to figure it how it works, but both fopen() and file_get_contents() worked for me

    Code:
    <?php
    $handle = file_get_contents("http://www.animeviews.com/test_text.txt",NULL);
    echo htmlentities($handle);
    ?>
    is mostly what I am going to use. I am using this to help out lindm in thread. I feel like I am working on a crossword puzzle and asking everyone what 6 across or 4 down is . Still, I am learning a lot and having too much fun

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •