note 80218 added to function.ftp-rawlist
| From: | weltvolk at osu1 dot php dot net | Date: | Fri, 04 Jan 2008 14:17:21 +0000 |
| Subject: | note 80218 added to function.ftp-rawlist | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-134768@lists.php.net to get a copy of this message | ||
With this handy function based on functions presented here you get the file list in alphabetical
order with all directories on top:
<?php
function rawlist_dump() {
global $ftp_connect;
$ftp_rawlist = ftp_rawlist($ftp_connect, ".");
foreach ($ftp_rawlist as $v) {
$info = array();
$vinfo = preg_split("/[\s]+/", $v, 9);
if ($vinfo[0] !== "total") {
$info['chmod'] = $vinfo[0];
$info['num'] = $vinfo[1];
$info['owner'] = $vinfo[2];
$info['group'] = $vinfo[3];
$info['size'] = $vinfo[4];
$info['month'] = $vinfo[5];
$info['day'] = $vinfo[6];
$info['time'] = $vinfo[7];
$info['name'] = $vinfo[8];
$rawlist[$info['name']] = $info;
}
}
$dir = array();
$file = array();
foreach ($rawlist as $k => $v) {
if ($v['chmod']{0} == "d") {
$dir[$k] = $v;
} elseif ($v['chmod']{0} == "-") {
$file[$k] = $v;
}
}
foreach ($dir as $dirname => $dirinfo) {
echo "[ $dirname ] " . $dirinfo['chmod'] . " | " .
$dirinfo['owner'] . " | " . $dirinfo['group'] . " | " .
$dirinfo['month'] . " " . $dirinfo['day'] . " " .
$dirinfo['time'] . "<br>";
}
foreach ($file as $filename => $fileinfo) {
echo "$filename " . $fileinfo['chmod'] . " | " .
$fileinfo['owner'] . " | " . $fileinfo['group'] . " | " .
$fileinfo['size'] . " Byte | " . $fileinfo['month'] . " " .
$fileinfo['day'] . " " . $fileinfo['time'] . "<br>";
}
}
rawlist_dump();
?>
----
Server IP: 217.13.201.10
Probable Submitter: 134.245.95.14
----
Manual Page -- http://www.php.net/manual/en/function.ftp-rawlist.php
Edit -- https://master.php.net/note/edit/80218
Del: integrated -- https://master.php.net/note/delete/80218/integrated
Del: useless -- https://master.php.net/note/delete/80218/useless
Del: bad code -- https://master.php.net/note/delete/80218/bad+code
Del: spam -- https://master.php.net/note/delete/80218/spam
Del: non-english -- https://master.php.net/note/delete/80218/non-english
Del: in docs -- https://master.php.net/note/delete/80218/in+docs
Del: other reasons-- https://master.php.net/note/delete/80218
Reject -- https://master.php.net/note/reject/80218
Search -- https://master.php.net/manage/user-notes.php