How can PHP be used to filter and display lines from a file based on a specific character, such as "="?

To filter and display lines from a file based on a specific character, such as "=", you can read the file line by line and use the strpos() function to check if the line contains the specific character. If the character is found, you can then display or process that line accordingly.

$file = fopen("example.txt", "r");

if ($file) {
    while (($line = fgets($file)) !== false) {
        if (strpos($line, "=") !== false) {
            echo $line;
        }
    }
    fclose($file);
} else {
    echo "Error opening file.";
}