that easy, great thanks is there easier way to do this, what troubles me if I make folders like this new1/new2/ if new1 dont exists i get error, I can branch only one folder not folder in folder in folder <?php $var1="sites"; $var2="files"; $var3="data"; $var4="test"; $v1=$var1; $v2=$var1."/".$var2; $v3=$var1."/".$var2."/".$var3; $v4=$var1."/".$var2."/".$var3."/".$var4; if (file_exists($v4)) { echo "Exists!"; } elseif (file_exists($v3)) { mkdir($v4, 0755); } elseif (file_exists($v2)) { mkdir($v3, 0755); mkdir($v4, 0755); } elseif (file_exists($v1)) { mkdir($v2, 0755); mkdir($v3, 0755); mkdir($v4, 0755); } else { mkdir($v1, 0755); mkdir($v2, 0755); mkdir($v3, 0755); mkdir($v4, 0755); } ?> PHP:
Leaving off the if exists test... <?php $directory=array('sites','files','data','test'); $v=''; foreach($directory as $var) { $v.=$var; mkdir($v,0755); } ?> PHP:
Great! I was looking today at foreach but I didn't understud what exactly would be $var so I gave up This is exactly what I was looking for, I can change arrays to make new1/new2/new3/new4 with / or make new folder branch without / Thanks <?php $directory=array('sites','/files','/data','/test'); $v=''; foreach($directory as $var) { $v.=$var; if (file_exists($v)) {} else { mkdir($v,0755); } } ?> PHP: