note 78282 deleted from function.ftp-nlist by nlopess

From: Date: Fri, 05 Oct 2007 11:55:52 +0000
Subject: note 78282 deleted from function.ftp-nlist by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-131129@lists.php.net to get a copy of this message
Note Submitter: webmaster at weltvolk dot de ---- How to get the file list in alphabetical order with all directories at the top: <?php $ftp_nlist = ftp_nlist($ftp_connect, "."); //alphabetical sorting sort($ftp_nlist); foreach ($ftp_nlist as $v) { //1. Size is '-1' => directory if (ftp_size($ftp_connect, $v) == -1) { //output as [ directory ] echo "[ " . $v . " ]<br />\n"; } } foreach ($ftp_nlist as $v) { //2. Size is not '-1' => file if (!(ftp_size($ftp_connect, $v) == -1)) { //output as file echo "" . $v . "<br />\n"; } } ?> Result looks like: [ a_mydirectory ] [ b_mydirectory ] [ c_mydirectory ] ... a_myfile.htm b_myfile.css c_myfile.php ...

« previous php.notes (#131129) next »