note 19078 added to ref.filesystem

From: Date: Fri, 15 Feb 2002 02:01:37 +0000
Subject: note 19078 added to ref.filesystem
Groups: php.notes 
Request: Send a blank email to php-notes+get-26629@lists.php.net to get a copy of this message
Barrowing from fancao0515@0451.com directory example and infomation gathered through out the internet, here is a basic example that will list the file information for MP3 files, given the path of the directory you would want to display, not this will do all sub directories. will only display the information if it is valid, hope someone likes it ;> <?PHP function mp3($filename) { $FP = fopen($filename,"r"); $succes = fseek($FP,-128,SEEK_END); $validtext=fread($FP,3); if(0==strcmp("TAG",$validtext)) { $Title=fread($FP,30); $Artist=fread($FP,30); $Album=fread($FP,30); $Year=fread($FP,4); $comments=fread($FP,30); $Genre=fread($FP,1); echo "This is the Information in a MP3 file Title <br>"; echo "Title: $Title <br>"; echo "Artist: $Artist <br>"; echo "Album: $Album <br>"; echo "Year: $Year <br>"; echo "Comments: $comments <br>"; echo "Genre: $Genre <P>"; } } function list_dir($dirname) { if($dirname[strlen($dirname)-1]!='\\') $dirname.='\\'; static $result_array=array(); $handle=opendir($dirname); while ($file = readdir($handle)) { $workdirsucces=chdir($dirname); if($file=='.'||$file=='..') continue; if(is_dir($dirname.$file)) list_dir($dirname.$file.'\\'); else $result_array[]=$dirname.$file; if(ereg (".mp3$", $file)) { call_user_func('mp3',$file); } } closedir($handle); return $result_array; } call_user_func ('list_dir', "C:\\Documents and Settings\\user\\My Documents"); ?> and that ends the wackyness, hope you have fun Cartman -- http://www.php.net/manual/en/ref.filesystem.php http://master.php.net/manage/user-notes.php?action=edit+19078 http://master.php.net/manage/user-notes.php?action=delete+19078 http://master.php.net/manage/user-notes.php?action=reject+19078

« previous php.notes (#26629) next »