Hoi,
Are you searching like that ?
$fFile = fopen ...
if($fFile)
{
$iCnt = 0;
$iMyLine = -1;
while(!feof($fFile) )
{
$sLine = fgets($fFile,1024);
if(strstr($sLine,"MYSEARCHSTRING") )
{
$iMyLine = $iCnt + 2;
}
if($iCnt == $iMyLine)
{
// $sLine contains the line i am searching for
}
$iCnt++;
}
}
The problem with this algorithm is, that if your searchstring is found in 2 lines that are side by side, than your iMyLine is overwritten by the next search result.
If you are just looking for one line in the code it will work 🙂