Reading particular line in a file for a particular word in PHP
<p>I am new to php, I need to read a text file's 5th line and see if it contains a particular string
what would be the most efficient way to do it ?
I understand I can ready all lines using this method, should I put a counter here and break the loop if it is 5 ? or is there a better way to it ..</p>

<pre><code> $file = fopen($fileName,'r');
    while(!feof($file)) 
    { 
        $name = fgets($file);            
    }

    fclose($file);
</code></pre>

<p>EDIT</p>

<p>I have updated my code to this, but strpos always fails to find the string even if it is present..
I have verified the 5th line looks like this
    PACKAGE_NAME: com.boom.appfree </p>

<pre><code>//read entire file into an array 
$lines = file($target_path);

//check line 5 if it contains free
$pos = strpos($line[4], 'free');

if ($pos === false) 
{
  $subject = "Paid Log uploaded";
} else 
{
   $subject = "Log uploaded";
}
</code></pre>

<p>Any advise please..</p>
