note 46439 added to function.opendir

From: Date: Mon, 11 Oct 2004 17:12:50 +0000
Subject: note 46439 added to function.opendir
Groups: php.notes 
Request: Send a blank email to php-notes+get-78360@lists.php.net to get a copy of this message
This is the way to put it in alphabetical order, im not sure of if its the best way to do it with arrays, but this is something i put together in about 5 min so it will at least give you the ide. <?php $dir = "/usr/home/freeshell/ruant/public_html"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $array = array($file); $r = array_merge($array, $r); } closedir($dh); } } sort($r); $tall = count($r); $i = 0; while ($i != $tall) { $i++; echo "<a href='$r[$i]'>$r[$i]</a><br>"; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.opendir.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46439 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46439&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46439&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78360) next »