Maverickb7 Posted October 11, 2006 Share Posted October 11, 2006 hello, I was wondering if someone could put me in the direction of some code that would take all files within a certain directory and put it into an array. Does anyone know where I can find this.. I'm trying to find some good examples. Link to comment https://forums.phpfreaks.com/topic/23623-displaying-directory/ Share on other sites More sharing options...
shiny_spoon Posted October 11, 2006 Share Posted October 11, 2006 I'm going to assume you meant file names and not data. ;)[code]<?php $i = 0; $path = 'my_directory'; $dir=opendir($path); while ($file=readdir($dir)) { if ($file != "." && $file != ".." && is_file($file) ) { $my_file_array[$i] = $file; $i++; } }?>[/code]I'm also going to assume you wanted only files in there and not folders. If this is incorrect, simply remove [code=php:0]&& is_file($file)[/code] from the [code=php:0]if[/code] statement! Link to comment https://forums.phpfreaks.com/topic/23623-displaying-directory/#findComment-107278 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.