Mkdir trick

This is sharing a trick only, at the moment.
Map an array list of directories to create with mkdir, and this avoids the need of recursion.

The default permissions are 777 when you pass no parameters to mkdir(). So:

$dirs = array(
# .... more list

array_map('mkdir', $dirs);

This would a nice job.

Did you recently ‘discover’ array_map() by any chance?

I meant to write repetition (looping). Typed recursion. :frowning:
These two codes are different.

First example makes directories anywhere, without recursion.
Second example directories inside directories.


$dir = '/some/dir/to/make'
mkdir($dir, 0777, true);

Third parameter = $recursive :slight_smile: