private function ftpDelete($directory)
    {
        // here we attempt to delete the file/directory
        if (!(@ftp_rmdir($this->ftp, $directory) || @ftp_delete($this->ftp, $directory))) {
            // if the attempt to delete fails, get the file listing
            $filelist = @ftp_nlist($this->ftp, $directory);

            // loop through the file list and recursively delete the FILE in the list
            foreach ($filelist as $file) {
                $this->ftpDelete($file);
            }

            // if the file list is empty, delete the DIRECTORY we passed
            $this->ftpDelete($directory);
        }
        return true;
    }
private function ftpDelete($directory)
    {
        // here we attempt to delete the file/directory
        if (!(@ftp_rmdir($this->ftp, $directory) || @ftp_delete($this->ftp, $directory))) {
            // if the attempt to delete fails, get the file listing
            $filelist = @ftp_nlist($this->ftp, $directory);

            // loop through the file list and recursively delete the FILE in the list
            foreach ($filelist as $file) {
                $this->ftpDelete($file);
            }

            // if the file list is empty, delete the DIRECTORY we passed
            $this->ftpDelete($directory);
        }
        return true;
    }
private function ftpDelete ( $ directory ) { // here we attempt to delete the file/directory if ( ! ( @ ftp_rmdir ( $ this -> ftp , $ directory ) || @ ftp_delete ( $ this -> ftp , $ directory ) ) ) { // if the attempt to delete fails, get the file listing $ filelist = @ ftp_nlist ( $ this -> ftp , $ directory ) ; // loop through the file list and recursively delete the FILE in the list foreach ( $ filelist as $ file ) { $ this -> ftpDelete ( $ file ) ; } // if the file list is empty, delete the DIRECTORY we passed $ this -> ftpDelete ( $ directory ) ; } return true ; }
Function to recursively delete folder, used for PHP FTP build in client.

@param $directory
@return bool
Function to recursively delete folder used for PHP FTP build in client .