How can the FILE_IGNORE_NEW_LINES flag in PHP's file function help prevent unwanted line breaks in merged tables?

When merging tables from multiple files using PHP's file function, unwanted line breaks can occur due to newline characters at the end of each line in the files. To prevent this, the FILE_IGNORE_NEW_LINES flag can be used with the file function to ignore these newline characters while reading the files.

// Merge tables from multiple files without unwanted line breaks
$mergedData = '';
$files = ['file1.txt', 'file2.txt', 'file3.txt'];

foreach($files as $file) {
    $data = file($file, FILE_IGNORE_NEW_LINES);
    $mergedData .= implode("\t", $data) . "\n";
}

echo $mergedData;