adam291086 Posted September 4, 2008 Share Posted September 4, 2008 ok i have a for loop for($i = 0; $i < count($values); $i++) { $newfile = $_SERVER['DOCUMENT_ROOT'].'/admin/FTP/code/zip/rubberduckiee files/'; $filename = $values[$i]; $filename = str_replace("/rubberduckiee", "", $filename); $filename= $_SERVER['DOCUMENT_ROOT'].$filename; $error = 0; if(is_file($filename)) { $trimFile = ereg_replace("^$currDir", "", $values[$i]); $trimFile = ereg_replace("^/", "", $trimFile); $newfile = $newfile.$trimFile; if (!copy($filename, $newfile)) { echo "failed to copy $filename...\n"; $error = 1; } } elseif(is_dir($filename)) { full_copy($filename, $newfile); } } if the $filename is a file then ok copy it. If its a dir then call on the function full_copy to copy it. I also want to add the $filename to an array if its a dir and i am not sure how. Any help is appreciated. Link to comment https://forums.phpfreaks.com/topic/122759-if-its-a-dir-then-add-it-to-an-array/ Share on other sites More sharing options...
genericnumber1 Posted September 4, 2008 Share Posted September 4, 2008 are you talking about $dirs[] = $filename; ? if so, just put it above the full_copy(...); line. Link to comment https://forums.phpfreaks.com/topic/122759-if-its-a-dir-then-add-it-to-an-array/#findComment-633943 Share on other sites More sharing options...
adam291086 Posted September 4, 2008 Author Share Posted September 4, 2008 i just want to be able to have an array and every time $filename is a dir then add it to this array, therefore building up a list Link to comment https://forums.phpfreaks.com/topic/122759-if-its-a-dir-then-add-it-to-an-array/#findComment-633945 Share on other sites More sharing options...
genericnumber1 Posted September 4, 2008 Share Posted September 4, 2008 then do as above Link to comment https://forums.phpfreaks.com/topic/122759-if-its-a-dir-then-add-it-to-an-array/#findComment-633949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.