A problem looping

software development

#1

$getID3 = new getID3; $dir = 'sermons'; $result = scandir ($dir); foreach ($result as $file) { echo 'scanning '; print "$file"; $fileinfo = $getID3->analyze($file); $title = $fileinfo['id3v2']['comments']['title'][0]; echo ($title); } I seem to be hitting a problem in this code wherein the foreach loop does not iterate through every element of $result. It stops after the first file, which is “.”. All I’m really after is the $title variable for all files in a directory, but I’m having problems isolating those.


#2

Try this:
$dir = ‘./sermons’;
$d=opendir($dir);
while (false !== ($results = readdir($d))) {
$result[]=$results;
}
foreach ($result as $title) {
if (preg_match(’/(comments|title)$/’, $title)) {
echo “$title\n”;
}
Hopefully this works, been awhile. what this should do is take each directory listing and put it in an array, then it will search for a directory name of comment or title and print that directory name.
Silk

My website


#3

Got it working. Thanks


#4

Glad you got it working, I was a little worried that I typed something wrong. lol.
Silk

My website