What are some potential pitfalls when using the PHP zip extension to extract files with a specified directory structure?
When using the PHP zip extension to extract files with a specified directory structure, a potential pitfall is that the extracted files may not be placed in the correct directories as intended. To solve this issue, you can use the `ZipArchive::extractTo()` method and specify the target directory path for extraction.
$zip = new ZipArchive;
if ($zip->open('example.zip') === TRUE) {
$zip->extractTo('/path/to/extracted/files/');
$zip->close();
echo 'Files extracted successfully';
} else {
echo 'Failed to extract files';
}