JREAM Posted November 28, 2008 Share Posted November 28, 2008 Im trying to get the WHILE loop to count numbers everytime it lists an item. Because I want to take the total mp3's in an array, and once it reaches the total divided by two, it makes another column which Ill insert in later.. function list_all_mp3 () { $directory = 'public/downloads/audio/'; $results = array(); $handler = opendir($directory); while ($file = readdir($handler)) { if ($file != '.' && $file != '..') { /*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*/ $mp3 = $file; $filesize = filesize($directory . $mp3); $fh = fopen($directory . $mp3, "r"); fseek($fh, -128, SEEK_END); $tag = fread($fh, 3); if($tag == "TAG") { $title = trim(fread($fh, 30)); $speaker = trim(fread($fh, 30)); } else die("MP3 file does not have any ID3 tag"); fclose($fh); echo "<ul class=\"audio\">\n"; echo "<li class=\"audiotitle\"> <img src=\"/public/images/icons/musicnote.gif\" /> <a name='$mp3' href='$directory$mp3'><strong>$title</strong></a></li>\n"; echo "<li class=\"notes audiodesc\"><strong>Speaker: </strong> $speaker</li> \n"; echo "<li class=\"notes audiodesc\"><strong>Size: </strong>" . ByteSize($filesize) ."</li>\n"; echo "</ul>"; /*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*/ } } closedir($handler); } ?> Link to comment https://forums.phpfreaks.com/topic/134622-how-to-count-a-while-loop/ Share on other sites More sharing options...
Mchl Posted November 28, 2008 Share Posted November 28, 2008 $i = 0; while (){ $i++; } Link to comment https://forums.phpfreaks.com/topic/134622-how-to-count-a-while-loop/#findComment-700917 Share on other sites More sharing options...
JREAM Posted November 29, 2008 Author Share Posted November 29, 2008 Oh man I thought i did this but musta messed it up in the bulk of code TY! Link to comment https://forums.phpfreaks.com/topic/134622-how-to-count-a-while-loop/#findComment-701638 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.