Home >Backend Development >PHP Tutorial >How to display file extensions, solve the problem of garbled file names after decompression, and code to transcode file names.
Copy code The code is as follows:
$a=zip_open('other.zip');
while ($e=zip_read($a)){
$fz = zip_entry_filesize($ e);
$fn = iconv('GBK','UTF-8',zip_entry_name($e));
if (!$fz){//dir
mkdir($fn);
continue;
}
if (!zip_entry_open($a, $e))
continue;
file_put_contents($fn, zip_entry_read($e, $fz));
echo "$fzt$fnn";
zip_entry_close($e);
}
zip_close($a);
?>
The above introduces how to display the file suffix name and solve the problem of garbled file names after decompression. The code for transcoding the file name includes how to display the file suffix name. I hope it will be helpful to friends who are interested in PHP tutorials.