How to use PHP mkdir function recursively to skip existing directory and to create new one from the string $pathname
// works fine if directories don't exist
mkdir($root_dir . '/demo/test/one', 0775, true);
// It will throw error - Message: mkdir(): File exists
mkdir($root_dir . '/demo/test/two', 0775, true);
What is the solution?
Your code should work as it is, the problem happens when/if you run it for the second time as per @chris85's suggestion you can check if their exists beforehand.