public static function emptyContents($dir) {
        $iterator = new \FilesystemIterator($dir, \FilesystemIterator::SKIP_DOTS);
        if (!$iterator->valid()) {
            return;
        }
        foreach($iterator as $fileinfo) {
            if ($fileinfo->isDir()) {
                self::deleteFolder($fileinfo->getPathname());
            }
            else {
                unlink($fileinfo->getPathname());
            }
        }
    }
public static function emptyContents($dir) {
        $iterator = new \FilesystemIterator($dir, \FilesystemIterator::SKIP_DOTS);
        if (!$iterator->valid()) {
            return;
        }
        foreach($iterator as $fileinfo) {
            if ($fileinfo->isDir()) {
                self::deleteFolder($fileinfo->getPathname());
            }
            else {
                unlink($fileinfo->getPathname());
            }
        }
    }
public static function emptyContents ( $ dir ) { $ iterator = new \ FilesystemIterator ( $ dir , \ FilesystemIterator :: SKIP_DOTS ) ; if ( ! $ iterator -> valid ( ) ) { return ; } foreach ( $ iterator as $ fileinfo ) { if ( $ fileinfo -> isDir ( ) ) { self :: deleteFolder ( $ fileinfo -> getPathname ( ) ) ; } else { unlink ( $ fileinfo -> getPathname ( ) ) ; } } }
Removes all the items in the given directory, while preserving the directory itself.

@param string $dir
Removes all the items in the given directory while preserving the directory itself .