note 89540 added to function.ftp-rawlist

From: Date: Thu, 12 Mar 2009 18:47:08 +0000
Subject: note 89540 added to function.ftp-rawlist
Groups: php.notes 
Request: Send a blank email to php-notes+get-151795@lists.php.net to get a copy of this message
Why not using POSIX regex to do the job here ? A preg_replace returns the information in an associative array with the following keys: <rights> <number> <owner> <group> <file_size> <mod_time> <file> <type> * that's a bonus: it will tell you if the item is either a file or a directory Code is shown below: $list=@ftp_rawlist($con,$directory) ; $items=array() ; foreach($list as $_) preg_replace( '`^(.{10}+)(\s*)(\d{1})(\s*)(\d*|\w*)'. '(\s*)(\d*|\w*)(\s*)(\d*)\s'. '([a-zA-Z]{3}+)(\s*)([0-9]{1,2}+)'. '(\s*)([0-9]{2}+):([0-9]{2}+)(\s*)(.*)$`Ue', '$items[]=array( "rights"=>"$1", "number"=>"$3", "owner"=>"$5", "group"=>"$7", "file_size"=>"$9", "mod_time"=>"$10 $12 $14:$15", "file"=>"$17", "type"=>print_r((preg_match("/^d/","$1"))?"dir":"file",1));', $_) ; # :p ---- Server IP: 69.147.83.197 Probable Submitter: 189.162.140.205 ---- Manual Page -- http://www.php.net/manual/en/function.ftp-rawlist.php Edit -- https://master.php.net/note/edit/89540 Del: integrated -- https://master.php.net/note/delete/89540/integrated Del: useless -- https://master.php.net/note/delete/89540/useless Del: bad code -- https://master.php.net/note/delete/89540/bad+code Del: spam -- https://master.php.net/note/delete/89540/spam Del: non-english -- https://master.php.net/note/delete/89540/non-english Del: in docs -- https://master.php.net/note/delete/89540/in+docs Del: other reasons-- https://master.php.net/note/delete/89540 Reject -- https://master.php.net/note/reject/89540 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151795) next »