How do I echo a specified line?

Discussion in 'PHP' started by SwiftKiwi, Jan 22, 2010.

  1. #1
    I have a a php script which writes data to a txt file.
    I want to be able to get or echo what is on a line that I specify of this file.

    If anyone can help me I would eb very greatful.
     
    SwiftKiwi, Jan 22, 2010 IP
  2. Gray Fox

    Gray Fox Well-Known Member

    Messages:
    196
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #2
    
    $text = file('yourfile.txt'); // Reads entire file into an array
    
    echo $text[$lineNumber]; // $text is zero-based array
    
    PHP:
     
    Gray Fox, Jan 22, 2010 IP