WEB problem counting lines in PHP

Discussion in 'OT Technology' started by MSTRMOO, Mar 17, 2009.

  1. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    so im counting lines in a text file in php.. however, once there are over like 15000 or 20000 lines, it wont display the number of lines, and it wont display anything further down in the code... like say i have some text after the line counting code.. the text wont be displayed..

    im using:

    $file2 = "http://www.website.com/file.txt";
    $lines2 = file($file2);
    $count2 = count($lines2);
    echo($count2);
     
  2. JoeyJoJoJuniorShabadoo

    JoeyJoJoJuniorShabadoo Live Free or Die

    Joined:
    Nov 9, 2004
    Messages:
    4,347
    Likes Received:
    0
    Location:
    http://www.stogietime.com
    try this:

    $i=0;
    $fp =fopen('file','r');
    while ($chunk = fread($p, 1024000)) {
    $i += substr_count($chunk, "\n");
    }
     
  3. JoeyJoJoJuniorShabadoo

    JoeyJoJoJuniorShabadoo Live Free or Die

    Joined:
    Nov 9, 2004
    Messages:
    4,347
    Likes Received:
    0
    Location:
    http://www.stogietime.com
    although, that wont work with some files
     
  4. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    it just seems like the code wont let it read past a certain number of lines.. i dont know what that number is, but today it stopped working at around 19700 lines... its basically logging traffic.. eventually ill make it create a new log file every day to avoid this.. but i plan on just paying someone to do this for me later on in like april..
     
  5. JoeyJoJoJuniorShabadoo

    JoeyJoJoJuniorShabadoo Live Free or Die

    Joined:
    Nov 9, 2004
    Messages:
    4,347
    Likes Received:
    0
    Location:
    http://www.stogietime.com

    yeah, in the example i showed, it does it in chunks instead of all at once
     

Share This Page