What potential issues can arise when creating multiple directories in PHP using nested if-else statements?
When creating multiple directories in PHP using nested if-else statements, potential issues can arise with readability and maintainability of the code. Nested if-else statements can quickly become complex and difficult to follow, especially when creating multiple directories. To solve this issue, consider using a more structured approach such as using switch statements or creating a separate function to handle directory creation.
// Example of creating multiple directories using a structured approach
$directories = ['dir1', 'dir2', 'dir3'];
foreach ($directories as $dir) {
if (!is_dir($dir)) {
mkdir($dir);
}
}