Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8019625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:26:37+00:00 2026-06-04T21:26:37+00:00

This will help anyone with JWPLAYER to make a playlist by scanning a folder

  • 0

This will help anyone with JWPLAYER to make a playlist by scanning a folder and creating the correct XML file automatically.

I would like to add one function which I can not work out.

I would like to order the play list by name or date.

 $folder = opendir($path);
$start="<asx version='3.0'>n<title>Example ASX playlist</title>";
$Fnm = "./playlist.xml";
$inF = fopen($Fnm,"w");
fwrite($inF,$start."n");
while( $file = readdir($folder) ) {
     if (($file != '.')&&($file != '..')&&($file != 'index.htm')){
     $result="<entry>n<title>$file</title>n<ref href='$path2$file'/>n<param name='image' value='preview.jpg'/>n</entry>n";
         fwrite($inF,$result);
     }
}
fwrite($inF,"</asx>");
closedir($folder);
fclose($inF);
?>

Question:

I would like to add to the above code a sort function by date before creating the XML and list.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:26:40+00:00Added an answer on June 4, 2026 at 9:26 pm

    You have to loop the directory and get the date with filemtime and dump it in an array, here’s a working script, you may change $path,$xmlfile or arsort() to sort() depanding on your needs …

    <?php
    
    $xmlfile = "playlist.xml";
    $path = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']). "/musicfolder";
    $folder = scandir($path);
    $files = array();
    foreach($folder as $file){
        if($file == '.' OR $file == '..' OR $file == 'index.htm'){}else{
            $files[$file] = filemtime($path.'/'.$file);
        }
    }
    arsort($files);
    
    //use asort to sort from old to new
    
    $output="<asx version='3.0'>" . PHP_EOL . "<title>Example ASX playlist</title>";
    foreach($files as $file => $date){
    $output .= "<entry>" . PHP_EOL . "<title>$file</title>" . PHP_EOL . "<ref href='$path'/>" . PHP_EOL . "<param name='image' value='preview.jpg'/>" . PHP_EOL . "</entry>" . PHP_EOL;
    }
    $output .= "</asx>";
    file_put_contents($xmlfile,$output);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will really appreciate help for this. My html v2 file with some temporary
This will help debugging, anyone knows how?
Can anyone help me in understanding how this will created 19 process? Main() {
Been banging our heads on this for two weeks now. Any help will be
I'm hittig my head on this and i will be glad for any help.
This is my first time on this site. I will ask you to help
[This will only make sense if you've seen Kevin Smith's 'Erlang in Practice' screencasts]
Hopefully this will be an easy one for anyone with any Django experience. I'm
This will probably be obvious but I can't find the best way. I want
This will be probable quite odd question. But i thought I will give it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.