Jump to content

How to Count a WHILE loop?


JREAM

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.