note 52406 added to function.ftp-rawlist

From: Date: Fri, 29 Apr 2005 17:14:56 +0000
Subject: note 52406 added to function.ftp-rawlist
Groups: php.notes 
Request: Send a blank email to php-notes+get-88762@lists.php.net to get a copy of this message
I'm not a traditional programmer, so I often take a different approach then most programmers. Here's how I get file information from an FTP file list. It's very simple (which I like). Comments are welcome: // make your FTP connection calls here, then ... $contents = ftp_rawlist($ftp_id, "."); echo '<TABLE>'; foreach ($contents as $key => $value) { $info = explode(" ", $value); $clean = array(); foreach ($info as $key => $value) { if (!empty($value)) { $clean[] = $value; } } // end foreach loop 2 if ( ($clean[8] != ".") AND ($clean[8] != "..") AND ($clean[8] != "html") AND ($clean[8] != "logs") AND ($clean[8] != "protected") AND ($clean[8] != "sys") ) { echo '<TR>'; print "<TD WIDTH=\"40%\">$clean[8]</TD>"; // name of file print "<TD WIDTH=\"20%\" ALIGN=\"CENTER\">$clean[5] $clean[6] $clean[7]</TD>"; // date info // prep size $size = $clean[4]; $size = $size / 1000; $size = ceil($size); if ($size <= 0) { $size = 1; } if ($size >= 1000) { $measure = "MB"; $size = $size / 1000; } else { $measure = "K"; } print "<TD WIDTH=\"20%\" ALIGN=\"CENTER\">$size $measure</TD>"; // size echo '<TD WIDTH="20%" ALIGN="CENTER" BGCOLOR="#FFFFE6" CLASS="bodyBold">'; print "<A HREF=\"$PHP_SELF?Submit=DELETE&file=$clean[8]\">"; echo 'DELETE</A></TD>'; // link to delete file echo '</TR>'; } // end if } // end foreach loop 1 echo '</TABLE>'; ---- Manual Page -- http://www.php.net/manual/en/function.ftp-rawlist.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52406 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52406&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52406&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52406&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52406&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52406&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52406&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88762) next »