note 102969 added to function.ftp-nlist

From: Date: Thu, 17 Mar 2011 10:35:36 +0000
Subject: note 102969 added to function.ftp-nlist
Groups: php.notes 
Request: Send a blank email to php-notes+get-177960@lists.php.net to get a copy of this message
We needed to get a list of all files in all subdirectories and couldn't see a method to do this so we wrote our own: /** * ftpRecursiveFileListing * * Get a recursive listing of all files in all subfolders given an ftp handle and path * * @param resource $ftpConnection the ftp connection handle * @param string $path the folder/directory path * @return array $allFiles the list of files in the format: directory => $filename * @author Niklas Berglund * @author Vijay Mahrra */ function ftpRecursiveFileListing($ftpConnection, $path) { static $allFiles = array(); $contents = ftp_nlist($ftpConnection, $path); foreach($contents as $currentFile) { // assuming its a folder if there's no dot in the name if (strpos($currentFile, '.') === false) { ftpRecursiveFileListing($ftpConnection, $currentFile); } $allFiles[$path][] = substr($currentFile, strlen($path) + 1); } return $allFiles; } ---- Server IP: 69.147.83.197 Probable Submitter: 88.131.29.2 ---- Manual Page -- http://www.php.net/manual/en/function.ftp-nlist.php Edit -- https://master.php.net/note/edit/102969 Del: integrated -- https://master.php.net/note/delete/102969/integrated Del: useless -- https://master.php.net/note/delete/102969/useless Del: bad code -- https://master.php.net/note/delete/102969/bad+code Del: spam -- https://master.php.net/note/delete/102969/spam Del: non-english -- https://master.php.net/note/delete/102969/non-english Del: in docs -- https://master.php.net/note/delete/102969/in+docs Del: other reasons-- https://master.php.net/note/delete/102969 Reject -- https://master.php.net/note/reject/102969 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177960) next »