public static function unlinkTargetFilesNotPresentInSource($source, $target)
    {
        $diff = self::directoryDiff($source, $target);
        $diff = self::sortFilesDescByPathLength($diff);

        foreach ($diff as $file) {
            $remove = $target . $file;

            if (is_dir($remove)) {
                @rmdir($remove);
            } else {
                self::deleteFileIfExists($remove);
            }
        }
    }
public static function unlinkTargetFilesNotPresentInSource($source, $target)
    {
        $diff = self::directoryDiff($source, $target);
        $diff = self::sortFilesDescByPathLength($diff);

        foreach ($diff as $file) {
            $remove = $target . $file;

            if (is_dir($remove)) {
                @rmdir($remove);
            } else {
                self::deleteFileIfExists($remove);
            }
        }
    }
public static function unlinkTargetFilesNotPresentInSource ( $ source , $ target ) { $ diff = self :: directoryDiff ( $ source , $ target ) ; $ diff = self :: sortFilesDescByPathLength ( $ diff ) ; foreach ( $ diff as $ file ) { $ remove = $ target . $ file ; if ( is_dir ( $ remove ) ) { @ rmdir ( $ remove ) ; } else { self :: deleteFileIfExists ( $ remove ) ; } } }
Removes all files and directories that are present in the target directory but are not in the source directory.

@param string $source Path to the source directory
@param string $target Path to the target
Removes all files and directories that are present in the target directory but are not in the source directory .