SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    array and reading from a file

    I want to read from a file (a file off a website) into an array.

    I want each element of the array to contain one line from this text website.

    How do I populate the array?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use file()


    http://www.php.net/file


    Example
    PHP Code:
    names.txt
    ==========
    Harry
    Bob
    Lisa
    Mary


    <?
    $data 
    file("names.txt");
    foreach(
    $data as $key => $val) {
       print 
    "$val<br>";
       }
    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •