note 110803 added to function.ftp-rawlist

From: Date: Mon, 10 Dec 2012 19:12:21 +0000
Subject: note 110803 added to function.ftp-rawlist
Groups: php.notes 
Request: Send a blank email to php-notes+get-192444@lists.php.net to get a copy of this message
Here's a simple function that'll parse the data returned by ftp_rawList() into an associative array. I wrote it because some of the functions listed below are way to long, complex or won't work with file names that contain spaces. <?php function listDetailed($resource, $directory = '.') { if (is_array($children = @ftp_rawList($resource, $directory))) { $items = array(); foreach ($children as $child) { $chunks = preg_split("/\s+/", $child); list($item['rights'], $item['number'], $item['user'], $item['group'], $item['size'], $item['month'], $item['day'], $item['time']) = $chunks; $item['type'] = $chunks[0]{0} === 'd' ? 'directory' : 'file'; array_splice($chunks, 0, 8); $items[implode(" ", $chunks)] = $item; } return $items; } // Throw exception or return false < up to you } ?> ---- Server IP: 91.199.167.223 Probable Submitter: 84.25.87.60 ---- Manual Page -- http://php.net/manual/en/function.ftp-rawlist.php Edit -- https://master.php.net/note/edit/110803 Del: integrated -- https://master.php.net/note/delete/110803/integrated Del: useless -- https://master.php.net/note/delete/110803/useless Del: bad code -- https://master.php.net/note/delete/110803/bad+code Del: spam -- https://master.php.net/note/delete/110803/spam Del: non-english -- https://master.php.net/note/delete/110803/non-english Del: in docs -- https://master.php.net/note/delete/110803/in+docs Del: other reasons-- https://master.php.net/note/delete/110803 Reject -- https://master.php.net/note/reject/110803 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192444) next »