What is the advantage of using the recursive parameter in mkdir() function in PHP 5 and above for creating nested directories?

When creating nested directories in PHP, using the recursive parameter in the mkdir() function allows you to create multiple directories at once, including any necessary parent directories that do not already exist. This eliminates the need to manually create each parent directory before creating the child directories.

// Example of using the recursive parameter in mkdir() function
$nestedDirectory = 'parent/child/grandchild';

// Create nested directories with a single call
mkdir($nestedDirectory, 0777, true);