note 68207 deleted from function.mkdir by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 19:15:58 +0000 |
| Subject: | note 68207 deleted from function.mkdir by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218707@lists.php.net to get a copy of this message | ||
Note Submitter: kungla at gmail dot com
----
Somehow the recursive version of mkdir didn't work for me on Mac and the workaraounds listed
below alsow didn't work for me, so heres my solution:
<?php
function mkdir_r($dirName, $rights=0777){
$dirs = explode('/', $dirName);
$dir='';
foreach ($dirs as $part) {
$dir.=$part.'/';
if (!is_dir($dir) && strlen($dir)>0)
mkdir($dir, $rights);
}
}
?>
Tested and works ;)