note 95326 deleted from function.ftp-nlist by danbrown

From: Date: Sun, 27 Dec 2009 20:06:18 +0000
Subject: note 95326 deleted from function.ftp-nlist by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164357@lists.php.net to get a copy of this message
Note Submitter: isooikgmailcom ---- You should just forget about this function, file_size() and the functions to check whether it's directory or not below. They are WAY TOO SLOW compared to my alternative, by using ftp_rawlist(). The code below is short but it's just to give you an idea of how to do it in a much faster way. Just implement the code in a function or whatever that suits your needs. <?php // Assuming $fh is the FTP connection resource $ftpRecords = ftp_rawlist($fh, '.'); foreach ( $ftpRecords as $line ) { // Get the name directory/file and size // $record[1]: size // $record[2]: file or directory name preg_match('/(\d+) [a-z]{3} \d{1,2} \d{2}:\d{2} (.+)$/i', $line, $record); $isDirectory = substr($line, 0, 2) == 'dr' ? true : false; // Now the rest } ?>

« previous php.notes (#164357) next »