note 95326 added to function.ftp-nlist

From: Date: Sun, 27 Dec 2009 16:46:16 +0000
Subject: note 95326 added to function.ftp-nlist
Groups: php.notes 
Request: Send a blank email to php-notes+get-164353@lists.php.net to get a copy of this message
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 } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 62.235.228.119 ---- Manual Page -- http://www.php.net/manual/en/function.ftp-nlist.php Edit -- https://master.php.net/note/edit/95326 Del: integrated -- https://master.php.net/note/delete/95326/integrated Del: useless -- https://master.php.net/note/delete/95326/useless Del: bad code -- https://master.php.net/note/delete/95326/bad+code Del: spam -- https://master.php.net/note/delete/95326/spam Del: non-english -- https://master.php.net/note/delete/95326/non-english Del: in docs -- https://master.php.net/note/delete/95326/in+docs Del: other reasons-- https://master.php.net/note/delete/95326 Reject -- https://master.php.net/note/reject/95326 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164353) next »