The code above works and I'm very happy with it, though I still have some concerns:
Lines 1-2, and as currently written lines 4-5 contain the regex split up on multiple lines. If possible I'd like to cut down on this bloated code and ideally make this into a single line.
Lines 1-3 are very similar to lines 4-6 with only a slight modification to handle file names between one and two characters long. If possible I'd appreciate feedback on how I could condense it down. I would love if the script could automatically decide how many subfolders to place itself into up to X-subfolders deep, such as 3-subfolders.
Line 8 no longer has any meaningful filename validation. If possible I'd like to incorporate this back in.
Line 8 passes all the subfolders into the $name variable (createPage.php?name=p/a/g/page-name). I'd like to change this so it only passes the last 'subfolder' name (createPage.php?name=page-name) but am having a difficult time with this as the files can now be various levels deep.
Again, I am very thankful for all the help and patients I have received so thus far. Thank you!