note 126383 deleted from function.mkdir by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 19:16:02 +0000 |
| Subject: | note 126383 deleted from function.mkdir by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218709@lists.php.net to get a copy of this message | ||
Note Submitter: yordanny90 at gmail dot com
----
To create a folder tree recursively so that all new folders have the same permissions:
<?php
function mkdir_recursive($directory, $permissions=0777) {
if(!file_exists(dirname($directory))){
mkdir_recursive(dirname($directory), $permissions);
}
if(mkdir($directory, $permissions)){
chmod($directory, $permissions);
return true;
}
return false;
}
?>