note 36701 added to function.ftp-rawlist

From: Date: Sun, 19 Oct 2003 09:39:02 +0000
Subject: note 36701 added to function.ftp-rawlist
Groups: php.notes 
Request: Send a blank email to php-notes+get-58882@lists.php.net to get a copy of this message
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.... ---- Manual Page -- http://www.php.net/manual/en/function.ftp-rawlist.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36701 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36701&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36701&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#58882) next »