The Problem:
I would like to know if there is a more practical way than using the IF/ELSE
control structures to create folders recursively, based on the inputs that the user typed.
Context:
For example, in my script, I get the data, validate it and sanitize it later, and then I create folders with the fields data informed, so far so good, but the problem is that some fields are not mandatory to be so I have, for example, 4 fields:
Name , Company , City / em>
I would like to know if there is any way other than IF/ELSE
:
$dir = "uploads/{$nome}/{$empresa}/{$cidade}/{$estado}/";
if(!is_dir($dir)):
mkdir($dir, 0777, true);
endif;
Create the folders with the data that was typed, ignoring the empty fields to avoid errors