Hello everyone,
Dave here. I’m new to the forum and I’m a “now and then” programmer of simple PHP. I’m on a project at work where I am the developer. (Fun stuff - no access to a database or FTP, all file uploads via a Movable Type interface, but I’m not building a Movable Type site.)
Anyway, my problem is this. I need to read the contents of a directory and echo the file names in numerical order (actually, in the long run, I need to echo the contents of the file, sorted numerically by file name, but that’s a hurdle I’ll cross once I get this figured out).
So far, I can read and echo the file names, but I can’t seem to sort them. I’ve tried various array things, but I’m starting to get in over my head. They keep echoing in the same order, so I’m assuming my attempts to sort and work with arrays isn’t working.
I’ve got a simple test script I’m using to break and fix as I try to figure it out. Here’s what I’ve got:
[php]
<?php if ($handle1 = opendir('./event-titles')) { while (false !== ($entry1 = readdir($handle1))) { if ($entry1 != "." && $entry1 != "..") { $remoteFile = "event-titles/".$entry1; $remoteFileContents = file_get_contents($remoteFile); echo "".$remoteFile.""; } } closedir($handle1); } ?>
[/php]
I’m surprised at how far I’ve gotten with other PHP-related parts of the site, but if you saw the code I’ve written you’d reach for the Maalox. Anything I do that needs to be stored gets written to a text file since databases aren’t available for me. What a joy. Anyway, ANY help anybody can provide would be appreciated. I really try to figure these things out on my own, and this is the first quandry that’s had me stumped to the point of begging for help.
Dave
(More fun stuff - I’m stuck with Windows XP and Internet Explorer 8 here at work.)