hosted by liquidweb

Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Problem reading/sorting a directory (PHP)

Forum Jump

Problem reading/sorting a directory (PHP)

Reply Post New Thread In Programming Discussion Subscription
Send news tip View All Posts Thread Tools Search this Thread Display Modes
Join Date: Apr 2004
Posts: 7

Problem reading/sorting a directory (PHP)

PHP Code:
if ($handle opendir('./favs')) {
$number 0;
        while (
false !== ($file readdir($handle))) {
                if (
$file != "." && $file != "..") {
$favsarray[$number] = $file;
$favsarray natsort($favsarray);
$i 0$i $number$i++) {
$fname$fext) = explode("."$favsarray[$i]);
$fname != 0) {
"<a href=\"now.php?fav=$fname\">$fname</a> ";
                } else {
"<a href=\"now.php?fav=$fname\">$fname</a><br />";
Apparently, $favsarray is blank, and $fname returns nothing, but, there is a 1.jpg in the ./favs directory.
Can anyone tell me what's wrong?
Edit/Delete Message

Sponsored Links
Junior Guru
Join Date: Oct 2001
Location: Ann Arbor, MI U.S.A.
Posts: 217

natsort doesn't return an array. You just use it like this:

PHP Code:
That should solve the blank array prob .


Chris Wells [clwells - at -]
Nexcess - Beyond Hosting
Dearborn, MI DC ● Southfield, MI DC
Wordpress Hosting, Magento Hosting & More!


Related posts from
Title Type Date Posted
Time is Running Out to Get Your Hottest Hosts Listing! Blog 2015-01-12 14:55:23
Microsoft Apologizes, Details Online Services Outage Web Hosting News 2014-06-30 10:29:39
Ads Available for the Second Printing of WHIR’s Annual Hottest Hosts Directory Blog 2014-04-08 16:52:36
Book Your Spot in the WHIR's 6th Annual Hottest Hosts Directory Before it's Too Late! Blog 2014-01-10 12:31:05
EIG Revenues: Higher than Reported Blog 2013-09-18 12:15:49

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Log in with your username and password

Forgot Password?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Web Hosting News:
WHT Membership
WHT Membership



Welcome to

Create your username to jump into the discussion! is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.

(4 digit year)

Already a member?