public function purge($dir)
    {
        if (!is_dir($dir)) {
            return;
        }

        $files = scandir($dir);

        if ($files !== false) {
            foreach ($files as $file) {
                if ($file === '.' || $file === '..') {
                    continue;
                }

                $path = $dir . '/' . $file;

                if (is_dir($path)) {
                    $this->purge($path);
                    rmdir($path);
                } else {
                    unlink($path);
                }
            }
        }
    }
public function purge($dir)
    {
        if (!is_dir($dir)) {
            return;
        }

        $files = scandir($dir);

        if ($files !== false) {
            foreach ($files as $file) {
                if ($file === '.' || $file === '..') {
                    continue;
                }

                $path = $dir . '/' . $file;

                if (is_dir($path)) {
                    $this->purge($path);
                    rmdir($path);
                } else {
                    unlink($path);
                }
            }
        }
    }
public function purge ( $ dir ) { if ( ! is_dir ( $ dir ) ) { return ; } $ files = scandir ( $ dir ) ; if ( $ files !== false ) { foreach ( $ files as $ file ) { if ( $ file === '.' || $ file === '..' ) { continue ; } $ path = $ dir . '/' . $ file ; if ( is_dir ( $ path ) ) { $ this -> purge ( $ path ) ; rmdir ( $ path ) ; } else { unlink ( $ path ) ; } } } }
Delete all files inside a directory.

@param string $dir

@return void
Delete all files inside a directory .