i have this code that is listing all my mp3 links in the directory, but the audio player won't play any files that have spaces in the file names, if i remove the spaces, it works but i was wondering if i can some how have the script add %20 when there is a space in the file name and that way the audio player i am using can pickup on it
Thanks!
heres my code
<ul id="playlist">
<?php
$dirFiles = array();
// opens images folder
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
// strips files extensions
$crap = array(".jpg", ".jpeg", ".JPG", ".JPEG", ".png", ".PNG", ".gif", ".GIF", ".bmp", ".BMP", "_", "-", "error_log", ".php");
$newstring = str_replace($crap, " ", $file );
//asort($file, SORT_NUMERIC); - doesnt work :(
// hides folders, writes out ul of images and thumbnails from two folders
if ($file != "." && $file != ".." && $file != "index.php" && $file != ".DS_Store" && $file != "download.php" && $file != "error_log" && $file != "Thumbnails") {
$dirFiles[] = $file;
}
}
closedir($handle);
}
sort($dirFiles);
foreach($dirFiles as $file)
{
//echo "<li><img style=\"padding-right: 10px;vertical-align: middle;height: 60px;\" src=\"http://www.ggcc.tv/LogoNE.png\" />";
echo '<li><a href="'.$file.'">'.$file.'<br></li>';
}
?>
</ul>