Jump to content

sir george

Recommended Posts

Newbie, first time ever posting.

 

I found this script online and it works exactly as I want with the exception of sorting. On my local host it presents output in alphabetical order, but online it will not. I've tried for days to work it into an array so I could sort it, but have hit my patience wall. Can someone please show me where to insert the array and then read it back? Thanks in advance for any effort put into this topic.

George

 

 

 

dir-read-script.php

Link to comment
Share on other sites

<?php$ltr = "a";$files = array();if ($handle = opendir("song-txt")) {  while (false !== ($file = readdir($handle))) {    if ($file != "." && $file != ".." && $file[0] == $ltr) {      //Truncate the file extension       $fileb =  (preg_replace('/..*$/', '', $file));       //Replace dash withspaces, capitalize words        $fileb= ucwords(str_replace("-"," ",$fileb));      $files[] = $fileb;    }  }} closedir($handle);sort($files);print_r($files);
Note that your server online probably has a case-sensitive filesystem, so if you're converting the case of the filenames you'll still need to use the original case to open the file.
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...