hosted by liquidweb


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

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
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
  #1  
Old 06-26-2004, 11:45 PM
ProdigySim ProdigySim is offline
Newbie
 
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;
                        
$number++;
                }
        }
        
$favsarray natsort($favsarray);
        for(
$i 0$i $number$i++) {
                list(
$fname$fext) = explode("."$favsarray[$i]);
                if(
$fname != 0) {
                        echo 
"<a href=\"now.php?fav=$fname\">$fname</a> ";
                } else {
                        echo 
"<a href=\"now.php?fav=$fname\">$fname</a><br />";
                }
        }
   
closedir($handle);
}
?>
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

Reply With Quote


Sponsored Links
  #2  
Old 06-27-2004, 12:18 AM
nexcess.net nexcess.net is offline
Junior Guru
 
Join Date: Oct 2001
Location: Ann Arbor, MI U.S.A.
Posts: 217
http://php.net/natsort

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

PHP Code:
natsort($favsarray); 
That should solve the blank array prob .

Chris

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

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Windows Azure Offers Active Directory in General Availability Web Hosting News 2013-04-09 14:09:20
50c21c1c-1d94-4ed4-adac-26fa45a79943 Listing 2013-03-05 18:26:32
Get listed in WHIR Magazine's 6th Annual Hottest Hosts Issue coming in January 2013 Blog 2012-12-28 11:03:01
Web Host Hostway Offers Compliant Ready Upgrade for Hosted Exchange Web Hosting News 2012-07-30 14:26:14
Get listed in WHIR Magazine's 5th Annual Hottest Hosts Issue coming in January 2012 Blog 2011-10-18 18:35:27


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
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com 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?