title: Reading specific line of a file in PHP
body: <p>I am working on reading a file in php.
  I need to read specific lines of the file.</p>
  
  <p>I used this code:</p>
  
  <pre><code>fseek($file_handle,$start);
  while (!feof($file_handle)) 
  {   
      ///Get and read the line of the file pointed at.
      $line = fgets($file_handle);
      $lineArray .= $line."LINE_SEPARATOR";
  
      processLine($lineArray, $linecount, $logger, $xmlReply);
  
      $counter++;
  }
  fclose($file_handle);
  </code></pre>
  
  <p>However I realized that the <code>fseek()</code> takes the number of bytes and not the line number. </p>
  
  <p>Does PHP have other function that bases its pointer in line numbers?</p>
  
  <p>Or do I have to read the file from the start every time, and have a
  counter until my desired line number is read?</p>
  
  <p>I'm looking for an efficient algorithm, stepping over 500-1000 Kb file to get to the desired line seems inefficient.</p>