Results 1 to 5 of 5

Thread: Fetching lines from a txt file.

  1. #1
    You're god damn right Barry's Avatar
    Join Date
    Jul 2003
    Posts
    1,484
    Thanks
    70
    Thanked
    75 times in 59 posts
    • Barry's system
      • Motherboard:
      • Gigabyte Z270M-D3H
      • CPU:
      • Intel i7 7700
      • Memory:
      • 16GB (2x8GB) Avexir 2400
      • Storage:
      • Samsung 860 256GB SSD, Sandisk Ultra 3D 500GB, LG BR Writer
      • Graphics card(s):
      • Evga GeForce GTX Titan X 12GB
      • PSU:
      • Corsair RM750I
      • Case:
      • Fractal Design Focus G
      • Operating System:
      • Windows 10 Professional
      • Monitor(s):
      • 28" Acer UHD 4K2K
      • Internet:
      • Sky Fibre

    Fetching lines from a txt file.

    I have a txt file that has game/player info from a server, the text file layout can't be changed.

    Code:
    WOL
    C&C_Complex.mix
    11
    1004
    11
    1011
    32
    0.27.02
    68
    beacht	NOD	92			199	000.41.42
    MAIKBISON	GDI	40			249	000.33.14
    HammerFZ1	NOD	11			120	000.01.34
    -=(MWV)=-Sizzle06	NOD	82			183	000.31.29
    Tater8Tot	GDI	216	0	0	502	000.02.37
    war24x7	GDI	51			152	000.29.58
    ravenf5r	NOD	37			106	000.12.10
    jerkout	NOD	61			215	000.28.30
    mugjr	NOD	18			175	001.40.04
    DispleasingSleeper	GDI	145			89	000.08.11
    Kpoch	NOD	16			179	001.19.05
    DIEFAST4M	GDI	110			242	000.42.58
    ravershaw	NOD	51			503	000.08.38
    rosin789	GDI	3			112	000.43.34
    dfa1989	NOD	39			113	000.51.35
    urmomafan	GDI	0			124	000.25.58
    vespilla	GDI	15			146	000.23.04
    Twisted Evil	NOD	496			124	005.04.15
    {GoC}-WL-Lmeeko	NOD	105	0	0	199	000.19.45
    alex7245	GDI	382			198	000.21.24
    {{PT}}Ryotsu(R)	GDI	39			288	000.21.10
    itch	GDI	0			120	000.43.32

    In PHP I'd like to fetch line 2 to 9, can ayone help, google has not been very friendly to me.
    Someone left a note on a piece of cake in the fridge that said, "Do not eat!". I ate the cake and left a note saying, "Yuck, who the hell eats paper ?

  2. #2
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Simple, move the file pointer to the second /n (if it's a UNIX file format), and buffer everything till the 9th.
    Last edited by aidanjt; 14-01-2007 at 10:43 PM.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  3. #3
    You're god damn right Barry's Avatar
    Join Date
    Jul 2003
    Posts
    1,484
    Thanks
    70
    Thanked
    75 times in 59 posts
    • Barry's system
      • Motherboard:
      • Gigabyte Z270M-D3H
      • CPU:
      • Intel i7 7700
      • Memory:
      • 16GB (2x8GB) Avexir 2400
      • Storage:
      • Samsung 860 256GB SSD, Sandisk Ultra 3D 500GB, LG BR Writer
      • Graphics card(s):
      • Evga GeForce GTX Titan X 12GB
      • PSU:
      • Corsair RM750I
      • Case:
      • Fractal Design Focus G
      • Operating System:
      • Windows 10 Professional
      • Monitor(s):
      • 28" Acer UHD 4K2K
      • Internet:
      • Sky Fibre
    Could you give me an example of this please?
    Someone left a note on a piece of cake in the fridge that said, "Do not eat!". I ate the cake and left a note saying, "Yuck, who the hell eats paper ?

  4. #4
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    http://www.php.net/manual/en/functio...m-get-line.php

    Just found this, might make things simpiler for you.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  5. #5
    You're god damn right Barry's Avatar
    Join Date
    Jul 2003
    Posts
    1,484
    Thanks
    70
    Thanked
    75 times in 59 posts
    • Barry's system
      • Motherboard:
      • Gigabyte Z270M-D3H
      • CPU:
      • Intel i7 7700
      • Memory:
      • 16GB (2x8GB) Avexir 2400
      • Storage:
      • Samsung 860 256GB SSD, Sandisk Ultra 3D 500GB, LG BR Writer
      • Graphics card(s):
      • Evga GeForce GTX Titan X 12GB
      • PSU:
      • Corsair RM750I
      • Case:
      • Fractal Design Focus G
      • Operating System:
      • Windows 10 Professional
      • Monitor(s):
      • 28" Acer UHD 4K2K
      • Internet:
      • Sky Fibre
    I have used an array to read line 2 to 8

    PHP Code:
    <?php

    $file_name 
    'status/aowstatus.txt';
    $array file($file_name);

    echo
    "Map: <font color='#009926'>";
    echo 
    $array[2]; 
    echo
    "</font><br />GDI: <font color='#A6A600'>";
    echo 
    $array[3];
    echo
    "</font><br />Score: <font color='#A6A600'>";
    echo 
    $array[4];
    echo
    "</font><br />Nod: <font color='#FF0000'>"
    echo 
    $array[5];
    echo
    "</font><br />Score: <font color='#FF0000'>"
    echo 
    $array[6];
    echo
    "</font><br />Time Remaining: <font color='#009926'>"
    echo 
    $array[7];
    echo
    "</font><br />SFPS: <font color='#009926'>";
    echo 
    $array[8];
    echo
    "</font>";
    ?>
    I could do this to read the rest (to get player names) but that could require making a huge array, ow could I read line 9 to the end of the file?
    Someone left a note on a piece of cake in the fridge that said, "Do not eat!". I ate the cake and left a note saying, "Yuck, who the hell eats paper ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help on my maxtor harddrives
    By arthurleung in forum PC Hardware and Components
    Replies: 10
    Last Post: 12-06-2007, 09:40 PM
  2. Multiple problems - help!
    By Ruggerbugger in forum Help! Quick Relief From Tech Headaches
    Replies: 7
    Last Post: 18-08-2006, 11:41 PM
  3. .NET Txt File Line counter
    By Shadow_101 in forum Software
    Replies: 5
    Last Post: 18-04-2006, 04:11 PM
  4. Nero vision express saying:'Burn process failed'
    By johnnr892 in forum Help! Quick Relief From Tech Headaches
    Replies: 15
    Last Post: 11-12-2005, 11:43 PM
  5. Dodgy DVD-r's ?
    By starside in forum Help! Quick Relief From Tech Headaches
    Replies: 12
    Last Post: 27-03-2005, 06:11 PM

Posting Permissions

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