public static function copyRecursive($source, $destination)
    {
        if (is_dir($source)) {
            $dir_handle = opendir($source);

            while ($file = readdir($dir_handle)) {
                if ($file != "." && $file != "..") {
                    self::mkDir($destination);

                    if (is_dir($source . "/" . $file)) {
                        if (!is_dir($destination . "/" . $file)) {
                            mkdir($destination . "/" . $file);
                        }
                        self::copyRecursive($source . "/" . $file, $destination . "/" . $file);
                    } else {
                        copy($source . "/" . $file, $destination . "/" . $file);
                    }
                }
            }
            closedir($dir_handle);
        } else {
            copy($source, $destination);
        }

        return true;
    }
public static function copyRecursive($source, $destination)
    {
        if (is_dir($source)) {
            $dir_handle = opendir($source);

            while ($file = readdir($dir_handle)) {
                if ($file != "." && $file != "..") {
                    self::mkDir($destination);

                    if (is_dir($source . "/" . $file)) {
                        if (!is_dir($destination . "/" . $file)) {
                            mkdir($destination . "/" . $file);
                        }
                        self::copyRecursive($source . "/" . $file, $destination . "/" . $file);
                    } else {
                        copy($source . "/" . $file, $destination . "/" . $file);
                    }
                }
            }
            closedir($dir_handle);
        } else {
            copy($source, $destination);
        }

        return true;
    }
public static function copyRecursive ( $ source , $ destination ) { if ( is_dir ( $ source ) ) { $ dir_handle = opendir ( $ source ) ; while ( $ file = readdir ( $ dir_handle ) ) { if ( $ file != "." && $ file != ".." ) { self :: mkDir ( $ destination ) ; if ( is_dir ( $ source . "/" . $ file ) ) { if ( ! is_dir ( $ destination . "/" . $ file ) ) { mkdir ( $ destination . "/" . $ file ) ; } self :: copyRecursive ( $ source . "/" . $ file , $ destination . "/" . $ file ) ; } else { copy ( $ source . "/" . $ file , $ destination . "/" . $ file ) ; } } } closedir ( $ dir_handle ) ; } else { copy ( $ source , $ destination ) ; } return true ; }
Copy folder content to another directory
@param string $source
@param string $destination
@return bool
Copy folder content to another directory