How can the options FILE_IGNORE_NEW_LINES and FILE_SKIP_EMPTY_LINES be beneficial when using the file() function in PHP?

When using the file() function in PHP to read a file into an array, the options FILE_IGNORE_NEW_LINES and FILE_SKIP_EMPTY_LINES can be beneficial. FILE_IGNORE_NEW_LINES removes newline characters from each element of the array, making it easier to work with the file content. FILE_SKIP_EMPTY_LINES excludes empty lines from the array, which can help in cases where you want to process only non-empty lines.

// Read file into an array with FILE_IGNORE_NEW_LINES and FILE_SKIP_EMPTY_LINES options
$fileLines = file('example.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

// Loop through the array and process each non-empty line
foreach ($fileLines as $line) {
    // Do something with the non-empty line
    echo $line . "<br>";
}