• PHP Create filelist array.
    2 replies, posted
Ok I admit it I am A dumbshit when it comes to php, So what I need is nice and simple and I will very much appreciate and learn from sampled code. I need a single php file that does this. Get all files in a single sub directory Output array of files Filename Filetype extension Filesize Something that I can use in a "foreach" loop. Thank you to everyone who contributes :D
[php] <?php $dir = '.'.DIRECTORY_SEPARATOR; #DIRECTORY_SEPARATOR must me appended to the end as it's used later on. foreach(scandir($dir) as $file){ $info = pathinfo($dir.$file); #Gets file info $files[] = array( 'name' => $file, 'size' => filesize($dir.$file), #Gets file size in bytes, divide by 1024 to iterate up the different byte sizes 'extension' => $info['extension'] ); } [/php] foreach($files as $info) etc
[QUOTE=Jelly;33281719][php] foreach($files as $info) etc[/QUOTE] HaHa! Thank you :3 Very easy to read too thanks :D
Sorry, you need to Log In to post a reply to this thread.