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. Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.