'Zip extract adds line breaks to each line
I have a zip file containing one file. I created the zip file and the file in it displays as expected. If I extract that file and copy it on my local WAMP server the destination file looks exatly as the original. But if I run the script on my Linux server, the destination file has line breaks after each line. So the contents of the original file are like this
line 1
line 2
line 3
while the contents of the destination file looks like this:
line 1
line 2
line 3
When the file is extracted it is left on disk. If I just issue a copy command to copy that file, the spacing in the destination file looks fine, on both servers. So it appears to be due to the copy command after the extract but how is that different from the straight copy? The code I'm using is below. I know I can read in file with ignore new lines and rewrite it but that seems wrong. Does anyone know how to fix this?
$zip = new ZipArchive;
if ($zip->open($myfile) === true) {
$filename = $zip->getNameIndex(0);
$zip->extractTo(".");
copy('myfile.php', 'some_dir/myfile.php');
$zip->close();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
