note 58301 added to function.opendir

From: Date: Mon, 31 Oct 2005 01:33:33 +0000
Subject: note 58301 added to function.opendir
Groups: php.notes 
Request: Send a blank email to php-notes+get-97849@lists.php.net to get a copy of this message
There's a simpler faster way to get a whole directory if you're using PHP 4. This function uses shell_exec - http://us3.php.net/shell_exec - and assumes you're using Unix/Linux and have shell access - function dir($directory){ $files=shell_exec("ls ".$directory); return explode("\n",$files); } This returns an array with all the files. This way, you can use modifiers like -t, which shows files in order of modification time ($files=shell_exec("ls -t ".$directory);). Enough tweaking and you can use it on Windows, though I can't say how since I don't have a Windows server to try it on ---- Manual Page -- http://www.php.net/manual/en/function.opendir.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58301 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58301&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58301&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58301&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58301&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58301&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58301&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58301&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58301&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97849) next »