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 Link to comment https://forums.phpfreaks.com/topic/268039-comma-after-line-beside-last-one/ Share on other sites More sharing options...
Jessica Posted September 5, 2012 Share Posted September 5, 2012 implode or trim Link to comment https://forums.phpfreaks.com/topic/268039-comma-after-line-beside-last-one/#findComment-1375590 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.