sir george Posted February 10, 2015 Share Posted February 10, 2015 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 More sharing options...
justsomeguy Posted February 10, 2015 Share Posted February 10, 2015 <?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. 1 Link to comment Share on other sites More sharing options...
sir george Posted February 11, 2015 Author Share Posted February 11, 2015 Thanks a million! I was right at the door, all over it, but just one little thing that I didn't see until you showed me. I sure apprediate the help. Respectfully, George Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now