note 36701 deleted from function.ftp-rawlist by crell
| From: | crell@php.net | Date: | Thu, 31 Mar 2022 19:31:11 +0000 |
| Subject: | note 36701 deleted from function.ftp-rawlist by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217909@lists.php.net to get a copy of this message | ||
Note Submitter: postmaster at alishomepage dot com
----
Here we go for a 100% working code... :D
<?
[code]
function cutspaces($str){
while(substr($str,0,1)==" "){$str=substr($str,1);}
return $str;}
[code]
$folders=array();
$files=array();
for($i=0;$i<sizeof($list);$i++){
list($permissions,$next)=split(" ",$list[$i],2);
list($num,$next)=split(" ",cutspaces($next),2);
list($owner,$next)=split(" ",cutspaces($next),2);
list($group,$next)=split(" ",cutspaces($next),2);
list($size,$next)=split(" ",cutspaces($next),2);
list($month,$next)=split(" ",cutspaces($next),2);
list($day,$next)=split(" ",cutspaces($next),2);
list($year_time,$filename)=split(" ",cutspaces($next),2);
if($filename!="." && $filename!=".."){
if(substr($permissions,0,1)=="d"){
$folders[]=$filename;
} else {
$files[]=$filename;}}}
sort($folders);
sort($files);
[code]
?>
so this will simply "get" all the information WITHOUT being in any case interfered with
some spaces, ... etc etc... It will even put files in a $files array and folders in a $folders
array, and sort them, so you will be able of using all this later
and: the "folders" will NOT contain "." and ".." ;)
so you can use all this to make a beautiful FTP interface... later on you could for example put
permissions and etc etc in other arrays to use them in your result... cute....