Jump to content

Duerdum9

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Duerdum9's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. First of, this is my script: <?php $newline = "\n"; $directory='music/'; $extensions = array('mp3', 'ogg'); $filesArray = array(); $dir_handle = @opendir($directory) or die("There is an error with your file directory!"); while ($file = readdir($dir_handle)) { $filePath = $directory.$file; $info = pathinfo($filePath); if(in_array(strtolower($info['extension']), $extensions)) { $filesArray[$info['filename']][$info['extension']] = $filePath; } } //sort($files_array, SORT_STRING); $path_parts = pathinfo('musicogg'); foreach ($filesArray as $fileName => $files) { if(count($files)==2) { echo '{'; echo 'mp3:"'.$files["mp3"].'",ogg:"'.$files["ogg"].''; echo '},'; echo $newline; } } ?> Okay, so what I need, is the file to type a comma after each line beside the very last one. Currently it does it with everyone, but that's giving errors, so any ideas? Really appreciated
  2. It changes quite often. But I've got it working now, for all of you out there that're having a similar issue this is the source code: http://slypaste.org/kWSJ8Ygi Feel free to copy and edit it as your liking
  3. So, two directories is simpler? As more simple is better & also, I don't know anything about JSON :L
  4. It doesn't matter if they are in the same directory or in separate, but I prefer having them in separate directories.
  5. Oh yeah, and one thing - Everytime I upload the .mp3 files, I upload the .ogg files, so that wouldn't be a problem. So there's exactly the same amount of songs with both .mp3 and .ogg - and they're the same songs.
  6. This code is broken, or something somehow: "if(in_array(strtolower($info['extension'])), $extensions)" - while getting this error "Parse error: syntax error, unexpected ','" - Tried removing the comma and stuff - doesn't work, any tips?
  7. It looks like the fields would always be in one directory. Anyway, I expect your problem is that the curly braces are in the wrong positions. Also, why hardcode the directory in that line when you made the directory a variable above? echo "mp3: \"{$directory}{$file_name}\"<br>\n"; http://themidlifecrisis.eu/musicplayer/ - Look at the source code. In the JS header - that's how I want the final output to be like, and of course way more songs. How would I do so?
  8. The problem is that there's about 200-300 songs, and for being able to use my HTML5 player to work in (almost) all browsers, it needs both .mp3 and .ogg.
  9. Hello, I was wondering if you could help me with the following file, and help me how to fix my error. <?php $directory='./music/'; $extension=''; $files_array = array(); $dir_handle = @opendir($directory) or die("There is an error with your file directory!"); while ($file = readdir($dir_handle)) { if($file{0}=='.') {continue;} if($extension == 'php'){ continue;} if($extension == 'htaccess') {continue;} $files_array[]=$file; } $file_downloads=sort($files_array,SORT_STRING); $path_parts = pathinfo('musicogg'); foreach ($files_array as $file_name){ //echo "{mp3:\"music/$file_name.mp3\"}"; echo $path_parts['extension'], "\n"; } ?> (removed spaces to compress it). Anyhow, the last few lines of code, where I've commented a line of code out - that's working as it should by going into the dir and checking all the files and echo'ing them. So this is what I want. I want it the final code to do this execute this line of code. {mp3:"music/name.mp3",ogg:"music/name.ogg"} - Notice, I do not really care if they the files need to be in one dir, or two dirs. How would I do, so it would show that in HTML, of course with all the files in the dir(s). (Note, name.mp3 & name.ogg is the same song). Thanks a ton
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.