Duerdum9 Posted September 5, 2012 Share Posted September 5, 2012 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 Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 5, 2012 Share Posted September 5, 2012 implode or trim Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.