Jump to content

if its a dir then add it to an array


adam291086

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.