Results 1 to 2 of 2

Thread: collect data from a .txt file

  1. #1
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default collect data from a .txt file

    Can someone help me get a page that will collect 2 words from a .txt file and then print the two words on the php page?

    The words are all on a separate link in the .txt file

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    PHP Code:
    <?php
    echo file_get_contents("file.txt");
    ?>
    Or, if you wanted to have some info in between them...
    PHP Code:
    <?php
    $stuff 
    file_get_contents("file.txt");
    $array explode(" ",$stuff);
    echo 
    "You are "$array[0] .", correct?";
    echo 
    "My name is "$array[1] .".";
    ?>
    That would give
    You are Brian, correct?
    My name is Jacob.

    with:
    Brian Jacob
    in the text file
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

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
  •