What are some best practices for reading and parsing specific lines in a text file using PHP?

When reading and parsing specific lines in a text file using PHP, it's important to open the file, read line by line, and then check each line to see if it matches the criteria you're looking for. You can use functions like `fgets()` to read each line and `strpos()` or `preg_match()` to check for specific patterns within the line. Once you find the line you're interested in, you can extract the data you need and process it accordingly.

$file = fopen("example.txt", "r");
if ($file) {
    while (($line = fgets($file)) !== false) {
        if (strpos($line, "specific_pattern") !== false) {
            // Parse the specific line here
            echo $line;
        }
    }
    fclose($file);
} else {
    echo "Error opening file.";
}