A problem looping

software development


$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.


Try this:
$dir = ‘./sermons’;
while (false !== ($results = readdir($d))) {
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.

My website


Got it working. Thanks


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

My website