I seemto have an issue with my loop in the below code. I have 3 mp3 files and 3 corresponding xml files for listing podcasts on my page. When displaying them on the page, it displays the first mp3 2 times, then the second mp3, then it displays mp3 1, 2, 3 in the correct order. Can anyone tell me why?
[code=php]
<?
include(“$absoluteurl”.”podcasts/core/supported_media.php”);
//load XML parser for PHP4 or PHP5
include_once(“$absoluteurl”.”podcasts/components/xmlparser/parser_php5.php”);
// Open podcast directory
$handle = opendir ($absoluteurl.$upload_dir);
while (($filename = readdir ($handle)) !== false)
{
if ($filename != ‘..’ && $filename != ‘.’ && $filename != ‘index.htm’ && $filename != ‘_vti_cnf’ && $filename != ‘.DS_Store’)
{
$file_array[$filename] = filemtime ($absoluteurl.$upload_dir.$filename);
}
}
if (!empty($file_array)) { //if directory is not empty
?>
<h2><img src=”images/podcast_icon.png” width=”20″ height=”20″ alt=”Podcasts” title=”Podcasts” class=”multimedia” /><a href=”/podcasts/” title=”Podcasts”>Podcasts</a></h2>
<?
# asort ($file_array);
arsort ($file_array); //the opposite of asort (inverse order)
//print_r($file_array);
$recent_count = 0; //set recents to zero
foreach ($file_array as $key => $value) {
$file_multimediale = explode(“.”,$key); //divide filename from extension [1]=extension (if there is another point in the filename… it’s a problem)
$fileData = checkFileType($file_multimediale[1],$podcast_filetypes,$filemimetypes);
if ($fileData != NULL) { //This IF avoids notice error in PHP4 of undefined variable $fileData[0]
$podcast_filetype = $fileData[0];
if ($file_multimediale[1]==”$podcast_filetype”) { // if the extension is the same as specified in config.php
$file_size = filesize(“$absoluteurl$upload_dir$file_multimediale[0].$podcast_filetype”);
$file_size = $file_size/1048576;
$file_size = round($file_size, 2);
############
$filedescr = “$absoluteurl”.”$upload_dir$file_multimediale[0].xml”; //database file
if (file_exists(“$filedescr”)) { //if database file exists
//$file_contents=NULL;
# READ the XML database file and parse the fields
include(“$absoluteurl”.”podcasts/core/readXMLdb.php”);
### Here the output code for the episode is created
# Fields Legend (parsed from XML):
# $text_title = episode title
# $text_shortdesc = short description
# $text_longdesc = long description
# $text_imgpg = image (url) associated to episode
# $text_category1, $text_category2, $text_category3 = categories
# $text_keywordspg = keywords
# $text_explicitpg = explicit podcast (yes or no)
# $text_authornamepg = author’s name
# $text_authoremailpg = author’s email
$PG_mainbody .=
‘<div class=”multimedia-list”>
<p>’.$text_title.'</p>’;
include (“$absoluteurl”.”podcasts/components/player/player.php”);
$PG_mainbody .= ‘<p>’.$showplayercode.'</p>’;
$PG_mainbody .= “</div>”;
echo $PG_mainbody;
}
}
}
}
}
?>
Here’s a link to the page: [URL=”http://www.zluth.org/multimedia/”]http://www.zluth.org/multimedia/
Thanks!