Jump to content

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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...