How do I search for text in a file?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Ahh, I am not able to test this but this should work(assuming you have previously opened the file):

Code: Select all

while (!feof($fp))
{
  $line = fgets($fp, 1024);
  if (preg_match("/Name=.*/", $line, $results)
  {
    $lineValues = explode("=", $line);
    print $lineValuesї1];
  }
}
Post Reply