note 44079 added to function.ftp-rawlist

From: Date: Wed, 14 Jul 2004 18:17:29 +0000
Subject: note 44079 added to function.ftp-rawlist
Groups: php.notes 
Request: Send a blank email to php-notes+get-73228@lists.php.net to get a copy of this message
Hi all ! ther is a litlle mistake in the naivesong 's message . Indeed , you stop to parse too early ... I tried and fix it like this : <? // getting the list $list = ftp_rawlist ($ftp_stream, $ftp_directory); $folders = array(); $files = array(); $links = array(); for ($i=0; $i<count($list); $i++) { //----convert tabs to blanks //----delete multiple blanks // Here begin my modifications list ($permissions, $list[$i]) = parsenext ($list[$i]); list ($number, $list[$i]) = parsenext ($list[$i]); list ($owner, $list[$i]) = parsenext ($list[$i]); list ($group, $list[$i]) = parsenext ($list[$i]); list ($size, $list[$i]) = parsenext ($list[$i]); list ($timeMonth,$list[$i]) = parsenext ($list[$i]); list ($timeDay,$list[$i]) = parsenext ($list[$i]); list ($timeTime,$list[$i]) = parsenext ($list[$i]); $filename=$list[$i]; // by taking $filename in last position , it works even if there is some space in its name //then we put it in the m array with the new things //----ok, put all this into the related array if ($filename != "." && $filename != "..") { $m = array(); $m["name"] = $filename; $m["link"] = $filelink; $m["size"] = afficherPoidsFichier($size); $m["month"] = $timeMonth; $m["day"] = $timeDay; $m["time"] = $timeTime; $m["owner"] = $owner; $m["group"] = $group; $m["permissions"] = $permissions; if (substr($permissions, 0, 1) == "d") $folders[count($folders)] = $m; else if (substr($permissions, 0, 1) == "l") $links[count($files)] = $m; else $files[count($files)] = $m; } } // you can sort $folders , $files , $links after if u want // afficherPoidsFichier($size) is a little function i found in this site at filesize() , works good ! // Just give the good size function afficherPoidsFichier($size) { $sizes = Array('o', 'Ko', 'Mo', 'Go'); $ext = $sizes[0]; for ($i=1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; } return round($size, 2).' '.$ext; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.ftp-rawlist.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44079 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44079&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44079&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#73228) next »